@patient = params[:id] should be changed to:
@patient = Patient.find params[:id]
Otherwise it''s just a string, and has no method called
"nlabs".
On May 5, 11:06 am, Anna
<anna1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> hi,
> I am trying to add a page to my exisiting database and for some reason
> I get an error of "no method" I searched a lot but my problem did
not
> get solved, so i''d appreciate if anyone can help me with this:
> I am trying to add a page called new_lab which is linked through my
> labs page, here is my controller:
> #new lab
> def show1
> @hide_sidebar = true
> @patient = Patient.find(params[:id])
>
> end
>
> def new_lab
> @hide_sidebar = true
> @patient = params[:id]
> @nlab = @patient.nlabs.build(:patient_id => @patient.id)
>
> end
>
> def create_lab
> @hide_sidebar = true
> @nlab = Nlab.new(params[:nlab])
> if @nlab.save
> flash[:notice] = ''Lab was successfully created.''
> redirect_to :action => ''show1''
> else
> render :action => ''new_lab''
> end
>
> end
>
> I get an error of "undefined method `nlabs''" and I
already made a
> model and a table by that name. I don''t understand what I am doing
> wrong.
>
> Thanks,
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group
athttp://groups.google.com/group/rubyonrails-talk?hl=en.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
groups.google.com/group/rubyonrails-talk?hl=en.