On May 8, 8:21 pm, Padmoja Roy <[email protected]> wrote:
> I was trying to make one to many relationships  -  between professors
> controller to rate_professors controller and used scaffold. it's
> giving me this error-
>
> NoMethodError in RateProfessorsController#index
> undefined method `rate_professors' for nil:NilClass
> app/controllers/rate_professors_controller.rb:7:in `index'
> Request
>
> Parameters:
> {"professor_id"=>"1"}
>
> here are the codes for two controllers and index page--
>
>   def index
>     @rate_professors = RateProfessor.all
>    professor = Professor.find(params[:professor_id])
>    @rate_professor =
> @Professor.rate_professors.build([professor:professor])

Ruby is telling you're calling the rate_professors method on nil on
this line, so your first step should be to have a look at this like.
You're calling it on @Professor which isn't initialized, therefore
it's nil. You've got the exact same mistake in a different action too.

Fred

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to