[Rails] No Method Error

Alana Murphy
Mon, 24 Apr 2006 10:13:21 -0000

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:

class RegisteredphoneController < ApplicationController
	layout "standard-layout"
	scaffold :registeredphone

	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
end

Any help would be appreciated!!