You can solve this issue by following way
> cd vendor/gems/authlogic-2.1.3
> gem specification authlogic > .specification
cheers,
Working with Ruby on Rails since july 2007. RoR web application development along with other technologies like LAMP.The reason to love programming with RoR is, it helps keep code simple, clean and nice… Also working with php/cakephp etc.
Wednesday, June 30, 2010
Thursday, June 24, 2010
Get Session Data Available in Models - Ruby on Rails
Sometimes we really need session variables inside model. But as the rails framework defines (MVC) pattern.
This pattern separates the context of the Web Application (Controller,View) from the Model. Model contains business logic of the web application. The Controller handles the interactions between the View and the Model.
So you can not access sessions directly in your model. You can crack it by following way.
This pattern separates the context of the Web Application (Controller,View) from the Model. Model contains business logic of the web application. The Controller handles the interactions between the View and the Model.
So you can not access sessions directly in your model. You can crack it by following way.
Create one module
module Utility
def current_user
Thread.current[:user]
end
def self.current_user=(user)
Thread.current[:user] = user
end
end
Add following in application controller
class ApplicationController < ActionController::Base
include Utility
before_filter :set_user_session
protected
def set_user_session
Utility.current_user = session[:user]
end
end
And now get it in your model
class Account < ActiveRecord::Base
include Utility
def before_create
unless allowed?(current_user)
return false
end
end
end
Subscribe to:
Posts (Atom)