[Rails] Re: No Method Error

Ray Baxter
Mon, 24 Apr 2006 23:03:10 -0000

Alana Murphy wrote:
> Hi,
>
> I''m new to rails and have stumbled across this error. Where am I
going
> wrong?!
>
>
> NoMethodError in Registeredphone#new
>
> Showing app/views/registeredphone/new.rhtml where line #15 raised:
>
> undefined method `user_id'' for #<Registeredphone:0x3874030>
>
> Extracted source (around line #15):
>
> 12:
> 13:    <% @user.each do |user| %>
> 14:        <option value="<%= user.id %>"
> 15:          <%= ''selected'' if user.id ==
@registeredphone.user_id %>>
> 16:          <%= user.txtForename %>
> 17:
> 18:    <% end %>
>
> My controller is as follows:


This error is telling you that your Registeredphone object doesn''t have
a user_id method which you attempt to use on line 15 of your view.

This could be because your registeredphones table doesn''t have a
user_id
column, or because you didn''t define a user_id method in your
Registeredphone model.

--

Ray