On Viernes, 3 de Septiembre de 2010 01:44:20 Poco Ritard escribió:
> Is there a recommended way of getting inplace_edit to check the
> controller authorization methods?  For example,
>
> class MyController < ApplicationController
>   layout "admin"
> ...
>
>     config.columns[:exclude].inplace_edit = true
>
> ...
>
>   def update_authorized?
>     session[:access_permissions].can_update
>   end
>
> AFACT it checks the @record authorizations (i.e. I can block it by
> adding
>
>    def exclude_authorized_for_update?
>     ...can't do much here, don't have the sesson :-(
>   end
>
> but it never checks the controller method.  Suggestions?

You can use current_user method in your models. It will call current_user 
method in current controller. If you have another method to return current 
user (for example current_login) you can use security.current_user_method so 
model.current_user method use that method:

  ActiveScaffold.set_defaults do |config|
    config.security.current_user_method = :current_login
  end

You can add a method in application controller, current_permissions to return 
session[:access_permissions], although I think is better to have current_user 
and get permissions through user model.

def current_permissions
  session[:access_permissions]
end
  ActiveScaffold.set_defaults do |config|
    config.security.current_user_method = :current_permissions
  end

You can set access permissions in a thread variable so you can access from 
your models:
before_filter :set_access_permissions
def set_access_permissions
  Thread.current[:access_permissions] = session[:access_permissions]
end


-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.

Reply via email to