Class: InvisibleController::Base
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- InvisibleController::Base
- Defined in:
- app/controllers/invisible_controller/base.rb
Constant Summary collapse
- RESTFUL_ACTIONS =
[:index,:create,:new,:edit,:show,:update,:destroy]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.belongs_to(parent_klass, args = {}) ⇒ Object
7 8 9 10 |
# File 'app/controllers/invisible_controller/base.rb', line 7 def self.belongs_to(parent_klass,args={}) @as ||= HashWithIndifferentAccess.new @as[parent_klass] = args[:as] end |
.has_scope(name, options = {}) ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/invisible_controller/base.rb', line 12 def self.has_scope(name,={}) raise NameError, "#{name} is an invalid scope name" if [:controller,:action,:format].include?(name.to_sym) @scopes ||= [] @scopes << name.to_s end |
Instance Method Details
#create ⇒ Object
28 29 30 |
# File 'app/controllers/invisible_controller/base.rb', line 28 def create resource.save(processed_params) ? respond : respond_with_errors end |
#destroy ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/invisible_controller/base.rb', line 31 def destroy if resource.destroy render response: 204, nothing: true else render json: resource_with_errors, status: 501 end end |
#update ⇒ Object
25 26 27 |
# File 'app/controllers/invisible_controller/base.rb', line 25 def update resource.update(processed_params) ? respond : respond_with_errors end |