Sonali Kapoor
2013-Mar-07 22:54 UTC
[ruby.mn] uninitialized constant Model1::Model2::Model3
I am getting `uninitialized constant Project::Forum::Topic` at app/controllers/home_controller.rb:46:in `discussions'' I have code below and I am converting from `rails 2.3.x` to `rails 3.2.11`, I am thinking something wrong in `routes` setting. Any Idea How can I fix? models Project < ActiveRecord::Base # Relations under project model has_many :features, :dependent => :destroy has_many :forums, :class_name=>''Forum::Forum'' has_many :topics, :class_name=>''Forum::Topic'', :through=>:forums Forum::Forum < Feature # Relations under forum model has_many :topics, :class_name => ''Forum::Topic'', :dependent => :destroy Feature < ActiveRecord::Base # Relations under feature model belongs_to :project Forum::Topic < ActiveRecord::Base # Relations under topic model belongs_to :forum, :foreign_key => :forum_id, :class_name => ''Forum::Forum'', :include => :project home_controller.rb def discussions @project ||= Project.find_by_name ''help'' @forums = @project.forums @topics = @project.topics.recent # HERE I AM GETTING ERRORS end routes.rb scope :home, :controller => "home", :activity => ''read'' do get :discussions, :path => ''/forums'', :service_type => ''public'' get :forums, :action => "discussions" end errors uninitialized constant Project::Forum::Topic app/controllers/home_controller.rb:46:in `discussions'' -- -- You received this message because you are subscribed to the Google Groups "ruby.mn" group. To post to this group, send email to rubymn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubymn+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubymn?hl=en --- You received this message because you are subscribed to the Google Groups "ruby.mn" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubymn+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
onaliapoor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2013-Mar-08 00:49 UTC
[ruby.mn] Re: uninitialized constant Model1::Model2::Model3
yes, those are in "app/models/forum", it is working fine with Rails 2.3.11 On Thursday, March 7, 2013 3:12:33 PM UTC-8, Chris Schneider wrote:> Are you putting those models in `app/models/project/forum/topic.rb` and > such? Rails assumes namespaces are subdirectories when trying to load up > classes. > > > On Thu, Mar 7, 2013 at 3:54 PM, Sonali Kapoor <onali...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<javascript:> > > wrote: > >> I am getting `uninitialized constant Project::Forum::Topic` at >> app/controllers/home_controller.rb:46:in `discussions'' >> >> I have code below and I am converting from `rails 2.3.x` to `rails >> 3.2.11`, I am thinking something wrong in `routes` setting. >> >> Any Idea How can I fix? >> >> models >> >> Project < ActiveRecord::Base >> # Relations under project model >> has_many :features, :dependent => :destroy >> has_many :forums, :class_name=>''Forum::Forum'' >> has_many :topics, :class_name=>''Forum::Topic'', :through=>:forums >> >> Forum::Forum < Feature >> # Relations under forum model >> has_many :topics, :class_name => ''Forum::Topic'', :dependent => >> :destroy >> >> Feature < ActiveRecord::Base >> # Relations under feature model >> belongs_to :project >> >> Forum::Topic < ActiveRecord::Base >> # Relations under topic model >> belongs_to :forum, :foreign_key => :forum_id, :class_name => >> ''Forum::Forum'', :include => :project >> >> home_controller.rb >> >> def discussions >> @project ||= Project.find_by_name ''help'' >> @forums = @project.forums >> @topics = @project.topics.recent # HERE I AM GETTING ERRORS >> end >> >> routes.rb >> >> scope :home, :controller => "home", :activity => ''read'' do >> get :discussions, :path => ''/forums'', :service_type => ''public'' >> get :forums, :action => "discussions" >> end >> >> errors >> uninitialized constant Project::Forum::Topic >> app/controllers/home_controller.rb:46:in `discussions'' >> >> -- >> You received this message because you are subscribed to the Google Groups >> "DeRailed - Denver Rails UG" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to derailed+u...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- -- You received this message because you are subscribed to the Google Groups "ruby.mn" group. To post to this group, send email to rubymn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubymn+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubymn?hl=en --- You received this message because you are subscribed to the Google Groups "ruby.mn" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubymn+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.