[Rails] Re: Relationship in Models

2010-01-07 Thread sushi 2k
Ankur wrote: > Hi ! > > According to your relationships: resource :has_many => roles > but you are using pro.roles. It means project should has many > roles.Its totally wrong accordingly. > > > First fetch all project_resources for a particular project. Eg. > > pr_resources = Project.find(1).p

[Rails] Re: Relationship in Models

2010-01-07 Thread Ankur
Hi ! According to your relationships: resource :has_many => roles but you are using pro.roles. It means project should has many roles.Its totally wrong accordingly. First fetch all project_resources for a particular project. Eg. pr_resources = Project.find(1).project_resources pr_resources wi

[Rails] Re: Relationship in Models

2010-01-07 Thread Shreyas Agarwal
As seen from above in Project class there is no relation ship defined for role so how can you expect the result from it. Add has_many :roles, :through => :projects_ressources and the required output will be produced. On Jan 7, 10:54 am, Sven Schleier wrote: > Hello, > I'm doing right now my fir

[Rails] Re: Relationship in Models

2010-01-06 Thread sushi 2k
> But I want also to know the roles of this ressources. How can I get now > the roles of the ressources to this project with id 1? This doesn't > work: > >>> role = pro.roles > > produces this error in the console: > > NoMethodError: undefined method `roles' for # > from > c:/Ruby/lib/r