Module: Zobi::Inherited
- Defined in:
- lib/zobi/inherited.rb
Overview
This module add some helpers to controllers.
* inherit_resources
* params filtering
Defined Under Namespace
Modules: Hidden
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object (also: #create!)
- #destroy ⇒ Object (also: #destroy!)
- #edit ⇒ Object
- #new ⇒ Object
- #update ⇒ Object (also: #update!)
Class Method Details
Instance Method Details
#create ⇒ Object Also known as: create!
21 22 23 24 25 26 27 |
# File 'lib/zobi/inherited.rb', line 21 def create r = zobi_resource_class.create permitted_params[zobi_resource_key] instance_variable_set "@#{resource_key}", r args = route_namespace args << r block_given? ? yield(r) : respond_with(*args) end |
#destroy ⇒ Object Also known as: destroy!
38 39 40 41 |
# File 'lib/zobi/inherited.rb', line 38 def destroy resource.destroy block_given? ? yield(resource) : redirect_to(collection_path) end |
#edit ⇒ Object
18 19 |
# File 'lib/zobi/inherited.rb', line 18 def edit end |
#new ⇒ Object
15 16 |
# File 'lib/zobi/inherited.rb', line 15 def new end |
#update ⇒ Object Also known as: update!
30 31 32 33 34 35 |
# File 'lib/zobi/inherited.rb', line 30 def update resource.update_attributes permitted_params[zobi_resource_key] args = route_namespace args << resource block_given? ? yield(resource) : respond_with(*args) end |