LoginEngine: undefined method `logged_in_at='


#1

Hi, just installed the LoginEngine.

I keep getting this error when I log in:

undefined method `logged_in_at=’

That is on line 22 of the user_controller:

def login
return if generate_blank
@user = User.new(params[:user]) # what does this achieve?
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 :action => ‘home’
else
@login = params[:user][:login]
flash.now[:warning] = ‘Login unsuccessful’
end
end

It is logging me in. But tripping up because it can’t find a logged_in
method.

If I comment out that line, it works fine. Any ideas what is wrong? And
whether commenting out this line will have consequences?

Thanks,

Steve


#2

The only function that line serves is to track when a particular user
logged in, so commenting it out shouldn’t be a huge issue.

As to why it’s causing you a problem… the line should simply
assign the current time into the logged_in_at field of the user table.
Did you use the migrations with the login engine to create your user
table? Can you verify that the table has a logged_in_at field?

  • james

#3

Thanks James.

I did not use migrations. I created my user table using the below from
the
bottom of the README file:

You need a database table corresponding to the User model. This is
provided
as a Rails Schema file, but the schema is presented below for
information.

mysql syntax:
CREATE TABLE users (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
login VARCHAR(80) NOT NULL,
salted_password VARCHAR(40) NOT NULL,
email VARCHAR(60) NOT NULL,
firstname VARCHAR(40),
lastname VARCHAR(40),
salt CHAR(40) NOT NULL,
verified INT default 0,
role VARCHAR(40) default NULL,
security_token CHAR(40) default NULL,
token_expiry DATETIME default NULL,
deleted INT default 0,
delete_after DATETIME default NULL
) TYPE=InnoDB DEFAULT CHARSET=utf8;

This does not contain a logged_in_at field. I think that is my problem.

Steve


#4

Gah - that SQL is now woefully out of date - I need to remove it.
Thanks, sorry for the confusion :slight_smile:

  • james

#5

No problem, thanks for your help.


#6

Patches are very welcome, even to documentation.

(hint, hint)

  • james

#7

James,

How about updating the sql rather than removing it? It was very helpful
to
me to understand the engine.

-bakki kudva


#8

Hi James,

I’d be happy to! I guess I’ll have to install the svn version to
generate
the diffs. When I first tried to install engines using svn it it didn’t
work. (on Debian Sarge with subversion 1.1.4-2) Don’t recall what the
error
messages were. So I just installed using ‘script/plugin install’. Now
the
question is do I need to uninstall what I have before trying svn version
or
can I install over it? What is the procedure for an uninstall? Just
delete
vendor/engines dir along with the tables? If I am successful in
Ajaxifying
the login/user engines I can submit those patches as well… may take me
a
while to figure it all out :slight_smile:

Thanks,

bakki


#9

Patches don’t need to be in diff format, but it does help. If you do
create any, they should be submitted to the Trac site (linked from
rails-engines.org).

To replace a plugin with another version, you can just move the
existing folder out of the way (either into another folder outside of
/vendor/plugins, or into /dev/null. i.e. oblivion) and replace it with
the new version. SVN is currently the only way to get specific
versions of the plugins that I’ve put up on rails-engines.org, but
there’s nothing special about the way that is set up. If you can’t
get:

svn co
http://opensvn.csie.org/rails_engines/login_engine/branches/rb_1.0
login_engine

to work, googling around with your particular error message should
point you in the right direction.

Thanks!

  • james

#10

I agree with Bakki. I just got bit by the same incorrect sql code on the
web page. We can do two things:

  1. Fix the code, which would be nice
  2. Indicate a little more clearly how to use the schema.rb file. I spent
    some time trying to figure it out, but I couldn’t. I want to learn it
    eventually, but it’s not my battle today. What’s not clear to me at this
    point is that it’s somehow tied to migrations, but I’m just trying to
    create a table, it seems like it should be one command.

Bakki K. wrote:

James,

How about updating the sql rather than removing it? It was very helpful
to
me to understand the engine.

-bakki kudva