Alias Action overwriting #20

Closed
alexcrichton opened this Issue Dec 23, 2009 · 3 comments

Comments

Projects
None yet
3 participants

If I do something like

alias_action :home, :to => :read

it overwrites the previous aliases for :read

On lib/cancan/ability.rb:159 I think the arrays should be merged like:
aliased_actions[target] = args | (aliased_actions[target] ||= [])

Current implementation is more clear when you know exactly what ought to be included in the alias list. Otherwise you have to dig in and find out defaults and whatever else might have been included.

Cool thing about declarative auth is that everything is in one place, and allowing appends to alias lists could break up the one-place-ness.

I'd propose leaving

alias_action :home, :to => :read

as it is, and adding

alias_action :home, :add => :read

(or :add_to or :append, etc)

Owner

ryanb commented Dec 31, 2009

I think merging the aliases makes more sense. Aliasing one thing to another usually does not clear the previous aliases. For example, alias in Ruby does not clear previous aliases to the method.

As for keeping everything in one place, this is already violated due to the default aliases. However I will add a clear_aliased_actions method which will remove previous and default aliases. This way one can start on a clean slate if he desires.

Owner

ryanb commented Dec 31, 2009

Append aliased actions (don't overwrite them) - closed by f99d506

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment