= BeforeActions {Gem Version}[http://badge.fury.io/rb/before_actions] {Inline docs}[http://inch-ci.org/github/yakko/before_actions] {Dependency Status}[https://gemnasium.com/yakko/before_actions] Wiki[https://github.com/before-actions-gem/before_actions/wiki] | RubyGems[https://rubygems.org/gems/before_actions] BeforeActions an elegant way of loading resorces in your restful controllers. == Installation In Rails 3 and Rails 4, add this to your Gemfile and run the +bundle+ command. gem "before_actions" bundle == Instructions == 1. Using the command class ContactsController < ApplicationController # load and authorize resources before_actions do # all actions # actions { } # list actions actions(:index) { @contacts = Contact.all } # building actions actions(:new) { @contact = Contact.new } actions(:create) { @contact = Contact.new(contact_params) } # member actions, will raise a 404 if the model is not found actions(:show, :edit, :update, :destroy) { @contact = Contact.find(params[:id]) } # all actions # actions { } end def contact_params params.require(:contact).permit(:name) end == 2. Enjoy your clean controller {contacts_controller.rb}[https://github.com/before-actions-gem/before_actions/blob/master/readme_images/contacts_controller.rb] {image}[https://github.com/before-actions-gem/before_actions] == 3. Nested Routes {image}[https://github.com/before-actions-gem/before_actions] == License Before Actions is released under the {MIT License}[http://www.opensource.org/licenses/MIT].