def login_submit if session[''user''] @logged_in = true else @logged_in = false end @user = User.new(params[''user'']) if session[''user''] = User.authenticate(params[''user''][''username''], params[''user''][''password'']) flash[:notice] = l(:user_login_succeeded) redirect_to :action => ''list'' else @login = params[''user''][''login''] flash.now[:notice] = l(:user_login_failed) end end ----------------------------------------------------------------------- FORM IS <div> <h1>Login Section</h1> <% form_tag :controller => "user", :action => "login_submit" do %> <p class="input_fields"><label>Username: </label><input id="user_username" name="user[username]" size="15" type="text" /></p> <p class="input_fields"><label>Password: </label><input id="user_password" name="user[password]" size="15" type="password" /></p><br clear="all" /> <%= submit_tag "Login"%> <% end %> </div> ------------------------------------------------------------------------ ERROR IS NoMethodError in UserController#login_submit undefined method `authenticate'' for #<Class:0x36f6cbc> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1532:in `method_missing'' app/controllers/user_controller.rb:34:in `login_submit'' -- 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 -~----------~----~----~----~------~----~------~--~---
do you have a user model with that method defined? On Wed, Apr 30, 2008 at 1:25 PM, Manish Nautiyal <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > def login_submit > if session[''user''] > @logged_in = true > else > @logged_in = false > end > @user = User.new(params[''user'']) > if session[''user''] = User.authenticate(params[''user''][''username''], > params[''user''][''password'']) > flash[:notice] = l(:user_login_succeeded) > redirect_to :action => ''list'' > else > @login = params[''user''][''login''] > flash.now[:notice] = l(:user_login_failed) > end > end > ----------------------------------------------------------------------- > FORM IS > > <div> > <h1>Login Section</h1> > <% form_tag :controller => "user", :action => "login_submit" do %> > <p class="input_fields"><label>Username: </label><input > id="user_username" name="user[username]" size="15" type="text" /></p> > <p class="input_fields"><label>Password: </label><input > id="user_password" name="user[password]" size="15" type="password" > /></p><br clear="all" /> > > <%= submit_tag "Login"%> > <% end %> > </div> > ------------------------------------------------------------------------ > ERROR IS > > NoMethodError in UserController#login_submit > > undefined method `authenticate'' for #<Class:0x36f6cbc> > > c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1532:in > `method_missing'' > app/controllers/user_controller.rb:34:in `login_submit'' > -- > 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 -~----------~----~----~----~------~----~------~--~---
HERE IS MY USER CONTROLLER--------- class UserController < ApplicationController layout "home" def list @user = User.find(:all) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save redirect_to :action => ''list'' else redirect_to :action => ''new'' end end def login @user = User.new @user.username = params[:user][:username] end def login_submit username = params[:user][:username] password = params[:user][:password] if session["user"] = User.authorize(username, password) @user = User.find(session["user"].id) @user.first_login = 1 @user.save flash[:notice] = "You are now logged in" redirect_to :action => ''create'' else flash[:error] = "Incorrect username and/or password" redirect_to :action => ''list'' end end end ----------------------------------------------------------------- HERE IS MY USER MODEL---- class User < ActiveRecord::Base validates_presence_of :username, :message=>"User Name will not b blank" validates_presence_of :password, :message=>"Password cannot be blank" end ----------------------------------------------------------------- -- 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 -~----------~----~----~----~------~----~------~--~---
You should have a method authenticate defined in User model. In your case, authenticate method must be defined in User model as class User < ActiveRecord::Base validates_presence_of :username, :message=>"User Name will not bblank" validates_presence_of :password, :message=>"Password cannot be blank" # # # # Authenticate method # # # def self.authenticate(login, pass) find(:first, :conditions=>["login = ? AND password = ?", login, pass]) # login, password are your users table fields.. end end On May 1, 9:09 am, Manish Nautiyal <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> HERE IS MY USER CONTROLLER--------- > > class UserController < ApplicationController > > layout "home" > > def list > @user = User.find(:all) > end > > def new > @user = User.new > end > > def create > @user = User.new(params[:user]) > if @user.save > redirect_to :action => ''list'' > else > redirect_to :action => ''new'' > end > end > > def login > @user = User.new > @user.username = params[:user][:username] > end > > def login_submit > username = params[:user][:username] > password = params[:user][:password] > if session["user"] = User.authorize(username, password) > @user = User.find(session["user"].id) > @user.first_login = 1 > @user.save > flash[:notice] = "You are now logged in" > redirect_to :action => ''create'' > else > flash[:error] = "Incorrect username and/or password" > redirect_to :action => ''list'' > end > end > end > ----------------------------------------------------------------- > HERE IS MY USER MODEL---- > > class User < ActiveRecord::Base > validates_presence_of :username, :message=>"User Name will not b > blank" > validates_presence_of :password, :message=>"Password cannot be blank" > end > ----------------------------------------------------------------- > -- > P osted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Thx prasad........... my prog is running successfully........ in future also if i have any problem i wil contact u........ can u give me u r email-id.... Thnx a lot....... :) -- 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 -~----------~----~----~----~------~----~------~--~---