On 4 July 2012 07:14, Abhishek Sharma <asharma...@gmail.com> wrote:
> class PageController < ApplicationController
>
>     before_filter :find_subject
>
>   def new
>     @page = Page.new(:subject_id => @subject.id)
>     @page_count = @subject.pages.size + 1
>     @subjects = Subject.order('position ASC')
>   end
>
>   private
>   def find_subject
>     if params[:subject_id]
>       @subject = Subject.find_by_id(params[:subject_id])
>     end
>   end
>
> end

You're calling find_subject on a before_filter, and it may or may not
populate a @subject object depending on whether there's a param value.

But your action then goes on to expect there to definitely be an
@subject instance variable. Put a breakpoint in find_subject, and see
what the parameter values are.

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

Reply via email to