Skip to content

Commit f2a4954

Browse files
committed
wip Add update lunchbox for admin
1 parent 0b78400 commit f2a4954

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

app/controllers/admin/lunchboxes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def create
3333
# PATCH/PUT /lunchboxes/1
3434
def update
3535
if @lunchbox.update(lunchbox_params)
36-
redirect_to @lunchbox, notice: 'Lunchbox was successfully updated.'
36+
redirect_to admin_lunchboxes_path, notice: 'Lunchbox was successfully updated.'
3737
else
3838
render :edit
3939
end
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
= form_for @lunchbox do |f|
1+
= form_for(@lunchbox, url: admin_lunchbox_path(@lunchbox)) do |f|
22
- if @lunchbox.errors.any?
33
#error_explanation
44
h2 = "#{pluralize(@lunchbox.errors.count, "error")} prohibited this lunchbox from being saved:"
55
ul
66
- @lunchbox.errors.full_messages.each do |message|
77
li = message
88

9+
fieldset
10+
.form-group
11+
= f.label :name
12+
= f.text_field :name, class: 'form-control'
13+
14+
.form-group
15+
= f.label :price
16+
= f.text_field :price, class: 'form-control'
17+
918
.actions = f.submit

app/views/admin/lunchboxes/edit.html.slim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ h1 Editing lunchbox
22

33
== render 'form'
44

5-
= link_to 'Show', @lunchbox
6-
' |
7-
= link_to 'Back', lunchboxes_path
5+
/= link_to 'Show', @lunchbox
6+
/' |
7+
/= link_to 'Back', lunchboxes_path
88

0 commit comments

Comments
 (0)