Playing around with Rails 4, I noticed that it defines a before_action
filter set_[model]
, that is called for the actions show
, edit
, update
and destroy
.
It is in fact very useful, but I don't see much sense in not having it to all member actions. After all, if you are using a member action, you want to act on that member, thus you need to recover it from database at some point.
Note that by member actions, I also means the ones configured on routes.rb
in the members
block.
Is there a straight-forward way to do this, without list all member actions on the before_action
filter?
Edit: To clarify, the whole point is use some rails magic to get all member routes and generate the array that would be pass in the :only
. So I can do something like
before_action set_model only: all_member_routes
where all_member_routes
is a piece of code that returns all member routes for my model.
Or even better,
before_action set_model, only_member_actions: true