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
grafikchaos edited this page Mar 27, 2012
·
8 revisions
To extend existing controller method functionality this pattern can be used: first alias the original method and then override the method, do some stuff and call the original method.
controllerdodefscoped_collectionend_of_association_chain.accessible_by(current_ability)endalias_method:update_ori,:updatealias_method:create_ori,:createdefupdate# don't allow a user to escape his constraintsparams[:user][:lessee_id]=current_user.lessee_idifcurrent_user.lessee_id?params[:user][:owner_id]=current_user.owner_idifcurrent_user.owner_id?update_ori# call original methodenddefcreate# don't allow a user to escape his constraintsparams[:user][:lessee_id]=current_user.lessee_idifcurrent_user.lessee_id?params[:user][:owner_id]=current_user.owner_idifcurrent_user.owner_id?create_ori# call original methodendend