Code snippet for application.rb that makes life just a little easier if multiple actions are doing exactly the same thing (both in the controller and the view):
def self.alias_action(existing, aliased) define_method(aliased.to_sym) do send(existing.to_sym) render :action => existing.to_s end end
And then in the appropriate controller (where
edit is an existing action, and
show needs to be exactly the same):
alias_action :edit, :show
I know this is a specialised use – but perhaps someone else out there is doing something similar.
2 responses to this article