ruby on rails - How to reference attributes in deep associations -


summary

rails 3.2 refinerycms 2.0. these pseudocode models:

industry   name   has_many companies   has_many works through companies  company    name   has_many works   belongs_to industry  work   name   belongs company 

from instance of work, can work.company.name , name of associated company. expect follow company.industry.name without problem. however, getting unhelpful error:

wrong constant name refinery:industries 

what follow associations way ie work.company.industry.name, chain broken between company , industry seems. doing wrong here? here's code in more detail.


code

here models. idea prevent me accessing industry attributes associated company given industries have_many companies (companys lol) , companies belong_to industry? appreciated.

industry model

module refinery   module industries     class industry < refinery::core::basemodel       ...        attr_accessible :name, :description, :position       has_many :companys, :class_name => '::refinery::companys::company', :dependent => :nullify       has_many :works, :through => :companys     end   end end 

company model

module refinery   module companys     class company < refinery::core::basemodel       ...        attr_accessible :name, :position, :industry_id       has_many :works, :class_name => '::refinery::works::work', :dependent => :destroy       belongs_to :industry, :class_name => '::refinery:industries::industry'     end   end end 

work model

module refinery   module works     class work < refinery::core::basemodel       ...        attr_accessible :name, :description, :position, :company_id       belongs_to :thumbnail, :class_name => '::refinery::image'       belongs_to :company, :class_name => '::refinery::companys::company'     end   end end 

then in erb file i'm doing this:

<% @works.each |work| %>               ...     <h5>       <%= work.company.name %>     </h5> <% end %>     

that 1 works.
1 gives me error though:

 <% @clients.each |client| %>    <h5>        <%= client.industry.name %>    </h5>  <% end %> 

that error reads:

wrong constant name refinery:industries 

there @ least double colon missing in company model:

belongs_to :industry, :class_name => '::refinery:industries::industry' 

should be

belongs_to :industry, :class_name => '::refinery::industries::industry' 

i haven't looked @ rest of code, first error.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -