module Outpost::Controller::ClassMethods
Attributes
fields[W]
model[RW]
Public Instance Methods
define_list(&block)
click to toggle source
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.
# File lib/outpost/controller.rb, line 81 def define_list(&block) @list = List::Base.new(model, &block) end
fields()
click to toggle source
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.
# File lib/outpost/controller.rb, line 49 def fields @fields ||= begin default_fields end end
list()
click to toggle source
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.
# 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={})
click to toggle source
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
# 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
Private Instance Methods
default_fields()
click to toggle source
# File lib/outpost/controller.rb, line 114 def default_fields model.column_names - Outpost.config.excluded_form_fields end
find_model()
click to toggle source
# File lib/outpost/controller.rb, line 118 def find_model self.name .demodulize .underscore .split("_")[0...-1] .join("_") .classify .constantize end