Module: ExpressAdmin::StandardActions::InstanceMethods

Defined in:
lib/express_admin/standard_actions.rb

Instance Method Summary collapse

Instance Method Details

#createObject



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/express_admin/standard_actions.rb', line 101

def create
  build_resource(resource_params)
  if resource.save
    respond_to do |format|
      format.html { redirect_to resource_path }
    end
  else
    respond_to do |format|
      format.html { render new_view, layout: defaults[:layout] }
    end
  end
end

#destroyObject



142
143
144
145
146
147
148
# File 'lib/express_admin/standard_actions.rb', line 142

def destroy
  load_resource
  resource.destroy!
  respond_to do |format|
    format.html { redirect_to collection_path }
  end
end

#editObject



122
123
124
125
126
127
# File 'lib/express_admin/standard_actions.rb', line 122

def edit
  load_resource
  respond_to do |format|
    format.html { render edit_view, layout: defaults[:layout] }
  end
end

#indexObject



86
87
88
89
90
91
92
# File 'lib/express_admin/standard_actions.rb', line 86

def index
  build_resource
  load_collection
  respond_to do |format|
    format.html { render index_view, layout: defaults[:layout] }
  end
end

#newObject



94
95
96
97
98
99
# File 'lib/express_admin/standard_actions.rb', line 94

def new
  build_resource
  respond_to do |format|
    format.html { render new_view, layout: defaults[:layout] }
  end
end

#showObject



114
115
116
117
118
119
120
# File 'lib/express_admin/standard_actions.rb', line 114

def show
  load_resource
  load_collection
  respond_to do |format|
    format.html { render show_view, layout: defaults[:layout] }
  end
end

#updateObject



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/express_admin/standard_actions.rb', line 129

def update
  load_resource
  if resource.update_attributes(resource_params)
    respond_to do |format|
      format.html { redirect_to resource_path }
    end
  else
    respond_to do |format|
      format.html { render edit_view, layout: defaults[:layout] }
    end
  end
end