Forum: Rails Engines Login Engine, Ruby on Rails and General Questions

Posted by Sasha Nark (nark)
on 2006-11-07 23:59
Hi guys, I am new to the forums and to Ruby on Rails as well. I am 
currently working on an application that requires a login form. I am 
using RadRails v 0.7.1 and a MySQL Server 5.0 database. I used the 
Salted Login Engine generator that came with RadRails to generate Login 
code. I also (for testing) generated using the scaffold generator a 
basic application. So far I got the login to work flawlessly where the 
user is able to login and is redirected to the main application. 
However, I had a problem with the following code:

def login
    return if generate_blank
    @user = User.new(params[:user])
    if session[:user] = User.authenticate(params[:user][:login], 
params[:user][:password])

 #    session[:user].logged_in_at = Time.now
      session[:user].save
      flash[:notice] = 'Login successful'
      redirect_to_stored_or_default :controller => 'admin', :action => 
'list'
    else
      @login = params[:user][:login]
      flash.now[:warning] = 'Login unsuccessful'
    end
  end

The commented out code was generating an error stating that the 
logged_in_at method did not exist. Is there really no such method? If 
so, why did the login_generator generate such code?

I am also trying to another field to the login form, Company name. 
However, I don't know how to do this. What code am I supposed to modify 
in order to authenticate against company name, user name and password? 
Also, how do I add this into the .rhtml code? I think I need to add 
another field to User.authenticate, but where is this method defined?

If someone can also give me a brief high level overview of how to Ruby 
on Rails works (how the controllers interact with the .rhtml files and 
with the helper files) that would be great. Any help is welcome, thanks.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.