Did you get a solution to this? On first glance, it may be because you
don''t have a password field in your database table - it''s
called
"hashed_password". Change "attr_accessor :password" to
"attr_accessor
:hashed_password", or run this against the database:
alter table users change hashed_password password char(40);
Just an idea.
Larry wrote:> I''m working through Dave Hunts new book. Trying to emplement the
login example.
> I set the following.
>
> create table users (
> id int not null auto_increment,
> name varchar(100) not null,
> hashed_password char(40) null,
> primary key (id)
> );
>
> model/user.rb
> ...
> attr_accessor :password
> ...
> end
>
> controller/application.rb
> ...
> model :user
> ...
> end
>
> controller/login
> ...
> def add_user
> @page_title = "Add a User"
> if request.get?
> @user = User.new
> else
> @user = User.new(params[:user])
> if @user.save
> redirect_to_index( "User #{@user.name} created")
> end
> end
> end
> ...
> end
>
> when I attempt to run this Rails gives me the following error:
>
> undefined local variable or method `password'' for User::User:Class
>
> /app/models/user.rb:8
> /home/prs6241/app/controllers/login_controller.rb:13:in `add_user''
>
>
>
> This error occured while loading the following files:
> user.rb
>
> What have I done wrong?
> Thanks,
> -Larry
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails