Class: RowsController
Class Method Summary
collapse
Instance Method Summary
collapse
#resource_format
#resource, #resources, #set_resource, #set_resources
#model_class, #model_name, #model_symbol, #model_symbol_plural
Class Method Details
.model_class(model_class = nil) ⇒ Object
19
20
21
22
23
24
|
# File 'app/controllers/rows_controller.rb', line 19
def self.model_class(model_class = nil)
return @_model_class if model_class.nil?
@_model_class = model_class
@_model_class = model_class.constantize if model_class.is_a?(String)
end
|
Instance Method Details
#create ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/rows_controller.rb', line 40
def create
set_resource model_class.new(resource_params)
msg = t("ui.created", model: model_name)
if resource.save
succeded msg, :create
else
failed :edit
end
end
|
#destroy ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/rows_controller.rb', line 59
def destroy
resource.destroy
msg = t("ui.destroyed", model: model_name)
flash[:notice] = msg unless request.xhr?
respond_to do |format|
format.html { redirect_to action: :index }
format.json { head :no_content }
end
end
|
#edit ⇒ Object
37
38
|
# File 'app/controllers/rows_controller.rb', line 37
def edit
end
|
#index ⇒ Object
26
27
28
|
# File 'app/controllers/rows_controller.rb', line 26
def index
set_resources model_class.all
end
|
#new ⇒ Object
33
34
35
|
# File 'app/controllers/rows_controller.rb', line 33
def new
set_resource model_class.new
end
|
#show ⇒ Object
30
31
|
# File 'app/controllers/rows_controller.rb', line 30
def show
end
|
#update ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'app/controllers/rows_controller.rb', line 50
def update
msg = t("ui.updated", model: model_name)
if resource.update(resource_params)
succeded msg, :ok
else
failed :edit
end
end
|