Forum: Rails Engines LoginEngine: undefined method `logged_in_at='

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-01-25 16:14
(Received via mailing list)
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
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-01-25 16:26
(Received via mailing list)
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
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-01-25 17:51
(Received via mailing list)
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.
<snip>

  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
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-01-25 18:00
(Received via mailing list)
Gah - that SQL is now woefully out of date - I need to remove it.
Thanks, sorry for the confusion :)

- james
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-01-25 18:43
(Received via mailing list)
No problem, thanks for your help.
8acba6d057b3f0c2c16cca95ad36881b?d=identicon&s=25 Bakki Kudva (bakki)
on 2006-01-25 20:35
(Received via mailing list)
James,

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

-bakki kudva
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-01-26 00:51
(Received via mailing list)
Patches are *very* welcome, even to documentation.

(hint, hint)

- james
8acba6d057b3f0c2c16cca95ad36881b?d=identicon&s=25 Bakki Kudva (bakki)
on 2006-01-26 14:59
(Received via mailing list)
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  :)

Thanks,

bakki
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-01-26 15:02
(Received via mailing list)
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...
login_engine

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

Thanks!

- james
3d9de7385f3767831cd228daef5650f9?d=identicon&s=25 MorganHillJoe (Guest)
on 2006-04-08 20:46
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 Kudva wrote:
> James,
>
> How about updating the sql rather than removing it? It was very helpful
> to
> me to understand the engine.
>
> -bakki kudva
This topic is locked and can not be replied to.