I am trying to implement the functionality of Remember Me. The
requirement is that once the user closes the browser after checking the
remember me check box, it should return to the login page with username
and password fields to be filled into the text boxes and the checkbox
button checked, so that there is no need to fill all the fields. I am
not able to fill the text boxes with user name and password fields.
`redirect_back’ is defined in authenticated_system.rb check it out
Yeah… I have installed the plugin acts_as_authenticated, and i got the
method
redirect_back in authenticated_system.rb. But still it is giving the
error
:undefined method `redirect_back’. Shall i need to include plugin in
some file? Please do tell me. The plugin is installed in vendor\plugin
directory.
can you please put the code here which you are using? or which is giving
error
yeah sure…
The code of login method in login controller:
def login
if user =
User.authenticate(params[:user][:login],params[:user][:password])
set_current_user user @userid = current_user.id @user = User.find_by_id(@userid) #render_text@user.login
if params[‘login’][‘secure’] == “1”
pid = UUID.random_create.to_s
current_user.secure = pid
cookies[:secure] = { :value => pid, :expires => Time.now + ( 90 *
(606024)) }
current_user.save
else
cookies.delete :secure
current_user.secure = nil
current_user.save
end
destination = session[:return_to] || { :controller =>
‘project’, :action => ‘list’}
redirect_to destination
else
flash[:notice] = ‘Invalid UserName or Password’
redirect_to :action => ‘index’
end
end
In login controller there is a method named login_form_cookie.
if !current_user.nil? && !cookies[:secure].nil?
if user = User.find_by_secure(cookies[:secure])
set_current_user user
session[:user]=params[:login]
redirect_to[‘REQUEST_URI’]
redirect_back(:controller => “login” , :action => “index”)
flash.now[:notice] = “Incorrect login!”
end
flash.now[:notice] = “Incorrect login!”
end