Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Auto define and assign controller (nested) instances variables from (nested) id(s)
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
MIT-LICENCE
README.rdoc
rails_zombie.gemspec

README.rdoc

Overview

Auto define controller model instance variable and nested instance variable(s) and assign their values from id and nested id

Usage

In ApplicationController, include RailsZombie. That's all.

Example

Suppose we have user controller nested on company

class ApplicationController < ...
  include RailsZombie
end

class UsersController < ApplicationController

  ....

  def show
    # You have @user and @company defined and assign from params[:id] and params[:company_id]
    # No need to do @user = User.find(params[:id]) and @company = Company.find(params[:company_id])
  end

  ....
end

/companies/2/users/1 => in controller you have @user with id 1 and @company with id 2 already defined.

Dependencies

require 'active_support/inflector'

Install

gem install 'rails_zombie'

Something went wrong with that request. Please try again.