I’m new to rails and have stumbled across this error. I’m not sure where
I am supposed to define the method user_id . I have included the
offending code and my controller. Can anyone help?!
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):
13: <% @user.each do |user| %>
14: <option value="<%= user.id %>"
15: <%= ‘selected’ if user.id == @registeredphone.user_id %>>
16: <%= user.txtForename %>
18: <% end %>
My controller is as follows:
class RegisteredphoneController < ApplicationController
def delete Registeredphone.find(@params['id']).destroy redirect_to :action => 'list' end def create @registeredphone = Registeredphone.new(@params['registeredphone']) @registeredphone.txtregisterdatetime = Time.now if @registeredphone.save redirect_to :action => 'list' else render_action 'new' end end def new @registeredphone = Registeredphone.new @user = User.find_all end def list @user = @params['user'] @registeredphones = Registeredphone.find_all end def edit @registeredphone = Registeredphone.find(@params["id"]) @user = User.find_all end
Any help would be appreciated!!