Skip to content

Commit

Permalink
wip Add update lunchbox for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
colorbox committed Jun 13, 2017
1 parent 818e258 commit 37b89ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/lunchboxes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create
# PATCH/PUT /lunchboxes/1
def update
if @lunchbox.update(lunchbox_params)
redirect_to @lunchbox, notice: 'Lunchbox was successfully updated.'
redirect_to admin_lunchboxes_path, notice: 'Lunchbox was successfully updated.'
else
render :edit
end
Expand Down
11 changes: 10 additions & 1 deletion app/views/admin/lunchboxes/_form.html.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
= form_for @lunchbox do |f|
= form_for(@lunchbox, url: admin_lunchbox_path(@lunchbox)) do |f|
- if @lunchbox.errors.any?
#error_explanation
h2 = "#{pluralize(@lunchbox.errors.count, "error")} prohibited this lunchbox from being saved:"
ul
- @lunchbox.errors.full_messages.each do |message|
li = message

fieldset
.form-group
= f.label :name
= f.text_field :name, class: 'form-control'

.form-group
= f.label :price
= f.text_field :price, class: 'form-control'

.actions = f.submit
6 changes: 3 additions & 3 deletions app/views/admin/lunchboxes/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ h1 Editing lunchbox

== render 'form'

= link_to 'Show', @lunchbox
' |
= link_to 'Back', lunchboxes_path
/= link_to 'Show', @lunchbox
/' |
/= link_to 'Back', lunchboxes_path

0 comments on commit 37b89ec

Please sign in to comment.