Displaying 2 results from an estimated 2 matches for "update_history".
2006 Apr 06
7
LoginSystem : make @session available to models
...session
@@session.call()
end
end
def session
self.class.session
end
end
end
Is this code OK ?
---
Now that this framework is set, I can store who did what on what on any
database update :
(In controllers/application.rb)
class ActiveRecord::Base
after_update :update_history
after_create :create_history
before_destroy :destroy_history
def update_history
history (''update'')
end
def create_history
history (''create'')
end
def destroy_history
history (''destroy'')
end
def history(action)
u...
2010 Mar 31
1
How to assign currently logged in user name to a table field
...user(id , username, password)
When a user "ABC" logs in and creates a new item, a history record gets
created with the following after_create filter.
How to set the username field in history table to "ABC".
class Item < ActiveRecord::Base
has_many :histories
after_create :update_history
def update_history
histories.create(:date=>Time.now, username=> ?)
end
My login method in user_controller
def login
if request.post?
user=User.authenticate(params[:username])
if user
session[:user_id] =user.id
redirect_to( :action=>''home''...