i have a project. the project has a status_id. i have a statuses table with id''s and names. the project model includes "has_one :status" the status model includes "has_many :projects" in my projects index page instead of project.status_id displaying 1, 2 or 3 i want to have the statuses.name accosiated with that id. i tied putting <%= project.status.name %> but i get the error, SQLite3::SQLException: no such column: statuses.project_id: SELECT * FROM "statuses" WHERE ("statuses".project_id = 6) LIMIT 1 it appears to be looking in statuses table for project_id not the other way around. can anyone clear this up for me? cheers, dave -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah, that is the way that the associations work. if a model ''has_one'' of something, then the something has the foreign key relationship back. It is described fairly nicely here: http://guides.rails.info/association_basics.html Simon On Wed, 07 Jan 2009 20:13:41 +0900, Dave Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i have a project. > > the project has a status_id. > > i have a statuses table with id''s and names. > > the project model includes "has_one :status" > > the status model includes "has_many :projects" > > in my projects index page instead of project.status_id displaying 1, 2 > or 3 i want to have the statuses.name accosiated with that id. > > i tied putting <%= project.status.name %> but i get the error, > > SQLite3::SQLException: no such column: statuses.project_id: SELECT * > FROM "statuses" WHERE ("statuses".project_id = 6) LIMIT 1 > > it appears to be looking in statuses table for project_id not the other > way around. > > can anyone clear this up for me? > > cheers, > > 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 -~----------~----~----~----~------~----~------~--~---
On Wed, Jan 7, 2009 at 12:13 PM, Dave Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i have a project. > > the project has a status_id. > > i have a statuses table with id''s and names. > > the project model includes "has_one :status"try belongs_to :status --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Franz Strebel wrote:> On Wed, Jan 7, 2009 at 12:13 PM, Dave Smith > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> i have a project. >> >> the project has a status_id. >> >> i have a statuses table with id''s and names. >> >> the project model includes "has_one :status" > > try belongs_to :statusi understand now! cheers guys -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---