Module: Refinery::Crud

Defined in:
lib/refinery/crud.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.append_features(base) ⇒ Object



43
44
45
46
# File 'lib/refinery/crud.rb', line 43

def self.append_features(base)
  super
  base.extend(ClassMethods)
end

.default_options(model_name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/refinery/crud.rb', line 19

def self.default_options(model_name)
  class_name = model_name.to_s.include?("/") ? "::#{model_name.to_s.camelize}" : model_name.to_s.camelize
  this_class = class_name.constantize.base_class
  singular_name = model_name.to_s.underscore.gsub("/","_")
  plural_name = singular_name.pluralize

  {
    :conditions => '',
    :include => [],
    :order => ('position ASC' if this_class.table_exists? and this_class.column_names.include?('position')),
    :paging => true,
    :per_page => false,
    :redirect_to_url => "admin_#{model_name.to_s.gsub('/', '_').pluralize}_url",
    :searchable => true,
    :search_conditions => '',
    :sortable => true,
    :title_attribute => "title",
    :xhr_paging => false,
    :class_name => class_name,
    :singular_name => singular_name,
    :plural_name => plural_name
  }
end