You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
koenhandekyn edited this page Mar 5, 2012
·
8 revisions
To extend existing controller method functionality this pattern can be used:
controller do
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
alias_method :update_ori, :update
alias_method :create_ori, :create
def update
# don't allow a user to escape his constraints
params[:user][:lessee_id] = current_user.lessee_id if current_user.lessee_id?
params[:user][:owner_id] = current_user.owner_id if current_user.owner_id?
update_ori # call original method
end
def create
# don't allow a user to escape his constraints
params[:user][:lessee_id] = current_user.lessee_id if current_user.lessee_id?
params[:user][:owner_id] = current_user.owner_id if current_user.owner_id?
create_ori # call original method
end
end