Module: Outpost::Controller::ClassMethods
- Defined in:
- lib/outpost/controller.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
Public: The fields for a form.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
-
#define_list(&block) ⇒ Object
Public: Define the list for this controller.
-
#list ⇒ Object
Public: The list for this controller.
-
#outpost_controller(attributes = {}) ⇒ Object
Public: Declare a controller as being a controller for Outpost.
Instance Attribute Details
#fields ⇒ Object
Public: The fields for a form.
If no fields have been defined, then the default fields will be used. Using the default fields will also set the permitted params to those fields.
Returns Array of fields.
49 50 51 52 53 |
# File 'lib/outpost/controller.rb', line 49 def fields @fields ||= begin default_fields end end |
#model ⇒ Object
Returns the value of attribute model.
39 40 41 |
# File 'lib/outpost/controller.rb', line 39 def model @model end |
Instance Method Details
#define_list(&block) ⇒ Object
Public: Define the list for this controller.
block - A block to define the list. See List::Base for more.
Examples
define_list do |l|
l.per_page = 50
l.column :name
end
Returns nothing.
81 82 83 |
# File 'lib/outpost/controller.rb', line 81 def define_list(&block) @list = List::Base.new(model, &block) end |
#list ⇒ Object
Public: The list for this controller.
If no list has been defined yet, this method will also define the list with the class’s default columns.
Returns the list.
61 62 63 64 65 66 67 |
# File 'lib/outpost/controller.rb', line 61 def list @list ||= define_list do |l| l.default_columns.each do |attribute| l.column attribute end end end |
#outpost_controller(attributes = {}) ⇒ Object
Public: Declare a controller as being a controller for Outpost.
model - (constant) The model for this controller.
Examples
class Admin::NewsStoriesController < Admin::ResourceController
outpost_controller model: NewsStory
end
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/outpost/controller.rb', line 95 def outpost_controller(attributes={}) @model = attributes[:model] || find_model include Outpost::Controller::Helpers include Outpost::Controller::Callbacks include Outpost::Controller::Actions include Outpost::Controller::Ordering include Outpost::Controller::Filtering include Outpost::Controller::Preferences before_filter :get_record, only: [:show, :edit, :update, :destroy] before_filter :get_records, only: [:index] before_filter :authorize_resource before_filter :filter_records, only: [:index] end |