Hi all, The login generator is currently broken on rails 0.10.0. both the path and the api for generators seem to have changed. I changed the login_generator.rb so it implements the new api. I don''t have a unit test, but it worked for me allowing me to generate my login. I attach my new file (a diff would yield almost all the lines anyway), if someone needs it until the author updates its package. I had to move the generator to the following location to make it work : {gems_install_dir}\1.8\gems\rails-0.10.0\lib\rails_generator\generators\components Jean _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Fri, 25 Feb 2005 16:49:51 +0100, Jean Helou <jean.helou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I changed the login_generator.rb so it implements the new api. I don''t > have a unit test, but it worked for me allowing me to generate my > login.Thanks for updating this... I was able to generate a login system under 0.10.0, but I''m having trouble getting the signup action working correctly. Has anyone gotten it to work? I was getting these errors with the default signup.rhtml view: (the controller is called "account") [snip] NoMethodError in Account#signup Showing /account/signup.rhtml where line #8 raised undefined method `login'' for #<User:0x3ce409b4 @new_record=true, @attributes={}> 5: <%= render_errors @user %><br/> 6: 7: <label for="user_login">Desired login:</label><br/> 8: <%= text_field "user", "login", :size => 30 %><br/> .... [/snip] I surmised this was because text_field tries to set the "value" attribute of the input tag to user.login, which doesn''t work, but isn''t necessary for input. I changed signup.rhtml as follows: <label for="user[login]">Desired login:</label><br/> <%= text_field_tag "user[login]", nil, :size => 30 %><br/> <label for="user[password]">Choose password:</label><br/> <%= password_field_tag "user[password]", nil, :size => 30 %><br/> <label for="user[password_confirmation]">Confirm password:</label><br/> <%= password_field_tag "user[password_confirmation]", nil, :size => 30 %><br/> That fixed the first warning, but after I submit the form I get a new one: [snip] NoMethodError in Account#signup undefined method `login='' for #<User:0x3cef17dc> /path/to/rails/app/controllers/account_controller.rb:22:in `new'' /path/to/rails/app/controllers/account_controller.rb:22:in `signup'' script/server:51 ..... Request Parameters: {:action=>"signup", :user=>{"password_confirmation"=>"test", "password"=>"test", "login"=>"testuser"}, :controller=>"account"} [/snip] I''m at a loss on that one... Has anyone else encountered or fixed this? FWIW: $ ruby -v ruby 1.8.2 (2004-12-25) [i386-openbsd3.6] $ gem list --no-details actionmailer (0.7.0) actionpack (1.5.0) actionwebservice (0.5.0) activerecord (1.7.0) activesupport (1.0.0) rails (0.10.0) rake (0.4.15) sources (0.0.1) Thanks for any help! [mp] -- Mike Pilat mpilat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hi Mike, On 27.2.2005, at 07:23, Mike Pilat wrote:> > Showing /account/signup.rhtml where line #8 raised undefined method > `login'' for #<User:0x3ce409b4 @new_record=true, @attributes={}> > > 5: <%= render_errors @user %><br/> > 6: > 7: <label for="user_login">Desired login:</label><br/> > 8: <%= text_field "user", "login", :size => 30 %><br/> > .... > [/snip] > > I surmised this was because text_field tries to set the "value" > attribute of the input tag to user.login, which doesn''t work, but > isn''t necessary for input.Not only that, it also pre-fills the input field if there is a @user object at hand.> I changed signup.rhtml as follows: > > <label for="user[login]">Desired login:</label><br/> > <%= text_field_tag "user[login]", nil, :size => 30 %><br/> > <label for="user[password]">Choose password:</label><br/> > <%= password_field_tag "user[password]", nil, :size => 30 %><br/> > <label for="user[password_confirmation]">Confirm > password:</label><br/> > <%= password_field_tag "user[password_confirmation]", nil, :size => > 30 %><br/> > > That fixed the first warning, but after I submit the form I get a new > one: > > [snip] > NoMethodError in Account#signup > > undefined method `login='' for #<User:0x3cef17dc> > > /path/to/rails/app/controllers/account_controller.rb:22:in `new'' > /path/to/rails/app/controllers/account_controller.rb:22:in `signup'' > script/server:51 > ..... > Request > > Parameters: {:action=>"signup", > :user=>{"password_confirmation"=>"test", "password"=>"test", > "login"=>"testuser"}, :controller=>"account"} > [/snip]You probably have something like this in your controller: @user = User.new(@params["user"]) That call will automatically call a setter method for all user params (like @user.login = "testuser"). If you then don''t have that setter method, you will get the nomethod error. What you probably want to do is to use the login value as you wish first, and then unset @params["user"]["login"] *before* you call User.new. Even simpler would be to use some other name for the field than "user[login]" because the login value here is not really (at this point) related to a single user object. //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails