loominator1970
2009-Feb-06 20:46 UTC
uninitialized constant error - Using unconventional table names
Hello,
I''m having some trouble with an association between two tables in my
RoR site. It looks like Rails is attempting to truncate the name of
my model so that it can fit the normal model conventions. Any idea
how I can override this?
The error:
uninitialized constant Project::ProjectProgres ( i think its
truncating the ''s'' off ''project_progress'' to
fit conventions)
The models (and associations)
#### ../models/project_progress.rb
class ProjectProgress < ActiveRecord::Base
set_table_name "project_progress"
belongs_to :project
#### ../models/project.rb
class Project < ActiveRecord::Base
has_many :project_progress
#### ../controllers/project_controllers.rb
......
@project.project_progress.each do |p| ## this is the line its
puking on
# some code
end
Any idea where to set the override statement?
Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Feb-07 12:38 UTC
Re: uninitialized constant error - Using unconventional table names
On Feb 6, 8:46 pm, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''m having some trouble with an association between two tables in my > RoR site. It looks like Rails is attempting to truncate the name of > my model so that it can fit the normal model conventions. Any idea > how I can override this? > > The error: > > uninitialized constant Project::ProjectProgres ( i think its > truncating the ''s'' off ''project_progress'' to fit conventions) > > The models (and associations) > > #### ../models/project_progress.rb > class ProjectProgress < ActiveRecord::Base > set_table_name "project_progress" > belongs_to :project > > #### ../models/project.rb > class Project < ActiveRecord::Base > has_many :project_progressA has_many should always use a plural form , regardless of what the underlying table name is, so has_many :project_progresses should work nicer. If Rails cannot properly infer the class name from the association name you can: - fiddle with the inflection rules so that rails knows how to singularize/pluralize these words - use the :class_name option Fred> > #### ../controllers/project_controllers.rb > ...... > @project.project_progress.each do |p| ## this is the line its > puking on > # some code > end > > Any idea where to set the override statement? > > Dave--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---