Skip to content

Auto define and assign controller (nested) instances variables from (nested) id(s)

License

Notifications You must be signed in to change notification settings

anoiaque/rails_zombie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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’

About

Auto define and assign controller (nested) instances variables from (nested) id(s)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages