Module: Godmin::Resource

Extended by:
ActiveSupport::Concern
Defined in:
lib/godmin/resource.rb,
lib/godmin/resource/scopes.rb,
lib/godmin/resource/filters.rb,
lib/godmin/resource/ordering.rb,
lib/godmin/resource/pagination.rb,
lib/godmin/resource/batch_actions.rb

Defined Under Namespace

Modules: BatchActions, Filters, Ordering, Pagination, Scopes

Instance Method Summary collapse

Instance Method Details

#attrs_for_formObject

Gives the view access to the list of attributes to be included in the default form



102
103
104
# File 'lib/godmin/resource.rb', line 102

def attrs_for_form
  []
end

#attrs_for_indexObject

Gives the view access to the list of column names to be printed in the index view



96
97
98
# File 'lib/godmin/resource.rb', line 96

def attrs_for_index
  []
end

#createObject



79
80
81
82
# File 'lib/godmin/resource.rb', line 79

def create
  @resource = resource_class.create(resource_params)
  respond_with(@resource)
end

#destroyObject



89
90
91
92
# File 'lib/godmin/resource.rb', line 89

def destroy
  @resource.destroy
  respond_with(@resource)
end

#editObject



75
76
77
# File 'lib/godmin/resource.rb', line 75

def edit
  respond_with(@resource)
end

#indexObject



63
64
65
# File 'lib/godmin/resource.rb', line 63

def index
  respond_with(@resources)
end

#newObject



71
72
73
# File 'lib/godmin/resource.rb', line 71

def new
  respond_with(@resource)
end

#resourceObject



55
56
57
58
59
60
61
# File 'lib/godmin/resource.rb', line 55

def resource
  if params[:id]
    resources_relation.find(params[:id])
  else
    resources_relation.new
  end
end

#resource_classObject



35
36
37
# File 'lib/godmin/resource.rb', line 35

def resource_class
  controller_name.classify.constantize
end

#resourcesObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/godmin/resource.rb', line 43

def resources
  apply_pagination(
    apply_order(
      apply_filters(
        apply_scope(
          resources_relation
        )
      )
    )
  )
end

#resources_relationObject



39
40
41
# File 'lib/godmin/resource.rb', line 39

def resources_relation
  resource_class.all
end

#showObject



67
68
69
# File 'lib/godmin/resource.rb', line 67

def show
  respond_with(@resource)
end

#updateObject



84
85
86
87
# File 'lib/godmin/resource.rb', line 84

def update
  @resource.update(resource_params)
  respond_with(@resource)
end