Module: ControllerResources::Extension::ClassMethods
- Defined in:
- lib/controller_resources/extension.rb
Overview
Macros included into the controller as class methods.
Instance Method Summary collapse
-
#resource(name = self.name.gsub(/Controller/, '').tableize, &block) ⇒ Object
Initialize this controller as an authenticated resource.
Instance Method Details
#resource(name = self.name.gsub(/Controller/, '').tableize, &block) ⇒ Object
Initialize this controller as an authenticated resource. You can optionally specify search_params and edit_params which are formed into strong parameter hashes.
Example:
resource :post do
search :title
modify :title, :body
end
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/controller_resources/extension.rb', line 56 def resource(name = self.name.gsub(/Controller/, '').tableize, &block) self._resource = Resource.new(name, &block) expose( _resource.model_name, except: i(index) ) expose( _resource.collection_name, only: i(index), attributes: :search_params ) end |