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:
return if generate_blank
@user = User.new(params[:user])
if session[:user] = User.authenticate(params[:user][:login],
session[:user].logged_in_at = Time.now
session[:user].save flash[:notice] = 'Login successful' redirect_to_stored_or_default :controller => 'admin', :action =>
@login = params[:user][:login]
flash.now[:warning] = ‘Login unsuccessful’
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.