# Undefined method

**URL:** <https://www.ruby-forum.com/t/undefined-method/188098>\
**Category:** Rails\
**Created:** [May 5, 2010, 5:41pm UTC](https://www.ruby-forum.com/t/undefined-method/188098 "2010-05-05T17:41:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anna](https://www.ruby-forum.com/u/anna)\
**Post date:** [May 5, 2010, 5:41pm UTC](https://www.ruby-forum.com/t/undefined-method/188098/1 "2010-05-05T17:41:36Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![anna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anna](https://www.ruby-forum.com/u/anna)\
**Post date:** [May 5, 2010, 5:53pm UTC](https://www.ruby-forum.com/t/undefined-method/188098/2 "2010-05-05T17:53:54Z")

</div>

@patient = params[:id] should be changed to:  
@patient = Patient.find params[:id]

Otherwise it’s just a string, and has no method called “nlabs”.
