I do not seem to understad what this error is about. Some body help. wrong number of arguments (1 for 2) RAILS_ROOT: C:/INSTAN~1/rails_apps/project/config/.. Application Trace | Framework Trace | Full Trace #{RAILS_ROOT}/app/controllers/user_controller.rb:10:in `authenticate'' #{RAILS_ROOT}/app/controllers/user_controller.rb:10:in `process_login'' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gilbert Gift Siima wrote:> I do not seem to understad what this error is about. Some body help. > > > wrong number of arguments (1 for 2) > RAILS_ROOT: C:/INSTAN~1/rails_apps/project/config/.. > > Application Trace | Framework Trace | Full Trace > #{RAILS_ROOT}/app/controllers/user_controller.rb:10:in `authenticate'' > #{RAILS_ROOT}/app/controllers/user_controller.rb:10:in `process_login''Hi Gilbert, It means that the method (authenticate, maybe) is expecting two arguments but you passed only one. Take a look at your user_controller about line 10 and see what it looks like. Post the code if you need to. Peace. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello all. I have been trying to develop an authentication program. I have been able to redirect a user to any page but have not been able to pesonalise it so that users can only access their personal accounts. thank you class UserController < ApplicationController def login @user = User.new @user.username = params[:username] end def process_login if user = User.authenticate(params[:user]) session[:id] = user.id && params[:username] != ''admin''# Remember the user''s id during this session #if User.username == ''admin'' redirect_to session[:return_to] || ''/customer/new'' else if user = User.authenticate(params[:user]) && params[:username] == ''admin'' session[:id] = user.id redirect_to session[:return_to] || ''/'' else flash[:error] = ''Invalid login.'' redirect_to :action => ''login'', :username => params[:user][:username] end end end def logout reset_session flash[:message] = ''Logged out.'' redirect_to :action => ''login'' end def my_account end end -- Love is the greatest --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 9/18/08, Gilbert Gift Siima <giftsiima-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:>> Hello all.>> I have been trying to develop an authentication program. I have been> able to redirect a user to any page but have not been able to> pesonalise it so that users can only access their personal accounts.> thank you>>I am using ruby 1.8 and here is my controller>> class UserController < ApplicationController>> def login>> @user User.new> @user.username = params[:username]>> end>> def process_login> if user = User.authenticate(params[:user])> session[:id] = user.id && params[:username] != ''admin''#> Remember the user''s id during this session>> #if User.username == ''admin''> redirect_to session[:return_to] || ''/customer/new''> else> > if user = User.authenticate(params[:user]) &&> params[:username] == ''admin''> session[:id] = user.id> redirect_to session[:return_to] || ''/'' > else> flash[:error] = ''Invalid login.''> redirect_to :action => ''login'', :username =>> params[:user][:username]> end> end>> end>> def logout> reset_session> flash[:message] ''Logged out.''> redirect_to :action => ''login''>> end>> def my_account> end> end>>> -- > Love is the greatest>> greatest --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
There are nice authentication frameworks out there.. I suggest trying those. You can use them or study them until you understand how to make your own. Check out http://railsforum.com/viewtopic.php?id=14216&p=1 On Thu, Sep 18, 2008 at 8:08 PM, Gilbert Gift Siima <giftsiima-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello all. > > I have been trying to develop an authentication program. I have been > able to redirect a user to any page but have not been able to > pesonalise it so that users can only access their personal accounts. > thank you > > > > class UserController < ApplicationController > > def login > > @user = User.new > @user.username = params[:username] > > end > > def process_login > if user = User.authenticate(params[:user]) > session[:id] = user.id && params[:username] != ''admin''# > Remember the user''s id during this session > > #if User.username == ''admin'' > redirect_to session[:return_to] || ''/customer/new'' > else > > if user = User.authenticate(params[:user]) && > params[:username] == ''admin'' > session[:id] = user.id > redirect_to session[:return_to] || ''/'' > else > flash[:error] = ''Invalid login.'' > redirect_to :action => ''login'', :username => params[:user][:username] > end > end > > end > > def logout > reset_session > flash[:message] = ''Logged out.'' > redirect_to :action => ''login'' > > end > > def my_account > end > end > > > -- > Love is the greatest > > > >-- Ramon Tayag --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---