Class: Georgia::WidgetsController
Instance Method Summary
collapse
#current_ability, #current_locale
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/georgia/widgets_controller.rb', line 16
def create
@widget = Widget.new(params[:widget])
if @widget.save
respond_to do |format|
format.html { redirect_to widgets_url, notice: "Widget was successfully updated." }
format.js { render layout: false }
end
else
respond_to do |format|
format.html { redirect_to widgets_url, alert: "Oups. Something went wrong." }
format.js { render layout: false }
end
end
end
|
#destroy ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/georgia/widgets_controller.rb', line 48
def destroy
@widget = Widget.find(params[:id])
if @widget.destroy
respond_to do |format|
format.html { redirect_to widgets_url, notice: "Widget was successfully deleted." }
format.js { head :ok }
end
else
respond_to do |format|
format.html { redirect_to widgets_url, alert: "Oups. Something went wrong." }
format.js { head :internal_server_error }
end
end
end
|
#edit ⇒ Object
12
13
14
|
# File 'app/controllers/georgia/widgets_controller.rb', line 12
def edit
@widget = Widget.find(params[:id])
end
|
#index ⇒ Object
6
7
8
9
10
|
# File 'app/controllers/georgia/widgets_controller.rb', line 6
def index
@widgets = Widget.order(:created_at).page(params[:page]).in_groups_of(4, false)
@widget = Widget.new
@widget.contents.build(locale: current_locale)
end
|
#update ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/georgia/widgets_controller.rb', line 33
def update
@widget = Widget.find(params[:id])
if @widget.update_attributes(params[:widget])
respond_to do |format|
format.html { redirect_to widgets_url, notice: "Widget was successfully updated." }
format.js { head :ok }
end
else
respond_to do |format|
format.html { render :index, alert: "Oups. Something went wrong." }
format.js { head :internal_server_error }
end
end
end
|