[Mongrel] Problem with mongrel_rails, but works with script/server

Luis Lavena luislavena at gmail.com
Mon Apr 19 13:21:18 EDT 2010


On Mon, Apr 19, 2010 at 2:07 PM,  <rpavesic at gmail.com> wrote:
> Hi Luis, thank you very much for the answer. Using eval (per your
> suggestion:)) I was
> able to start debugging the problem.
> The error shows up when executing the following statement:
> @customers=provider.customers
>
> Here is the full error log that
> gets shown on the browser:
> ------>>>>>---------
>
> undefined method `reflect_on_association' for Service:Module
>
> RAILS_ROOT: C:/RubyOnRails/rails_apps/msms
> Application Trace | Framework Trace | Full Trace
>
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/reflection.rb:257:in `source_reflection'
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/reflection.rb:257:in `collect'
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/reflection.rb:257:in `source_reflection'
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/reflection.rb:288:in `check_validity!'
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/associations/has_many_through_association.rb:5:in `initialize'
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/associations.rb:1277:in `new'
> C:/RubyOnRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_rec
> ord/associations.rb:1277:in `customers'
> C:/RubyOnRails/rails_apps/msms/app/controllers/doctor_controller.rb:17:in
> `index'
> ---------<<<<<<<<<-----
>
> I have the following relatonships relating to this problem in my models:
>
> class Provider < ActiveRecord::Base
>        has_many :services
>        has_many :customers, :through => :services
>      ......
>        .....
> end
>
> class Service < ActiveRecord::Base
>        belongs_to :provider
>        belongs_to :customer
>        belongs_to :invoice
>      ......
>        .....
> end
>
> class Customer < ActiveRecord::Base
>        has_many :services
>        has_many :providers, :through => :services
>        has_many :invoices, :dependent=> :destroy
>      ......
>        .....
> end
>
> class Invoice < ActiveRecord::Base
>        has_many :services
>        belongs_to :customer
>      ......
>        .....
> end
>
> What is puzzling is that if I use "script/server" (which starts the mongrel)
> all works fine,
> but if I use "mongrel_rails start" this error shows up. What is diffenrent
> under the hub between
> these two?

script/server initializes Rails before Mongrel, while mongrel_rails
does the opposite.

Since you've installed mongrel_service gem, it defines a Service
module, which is used as plugin to install inside mongrel how command
functionality:

http://github.com/fauna/mongrel_service/blob/master/lib/mongrel_service/init.rb#L8-9

If you aren't using mongrel_service, I would suggest you remove the gem.

The problem is that the plugin for mongrel can't be named differently.
If we do, then will break compatibility with old versions.

-- 
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry


More information about the Mongrel-users mailing list