File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed
Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def create
2424 @lunchbox = Lunchbox . new ( lunchbox_params )
2525
2626 if @lunchbox . save
27- redirect_to @lunchbox , notice : 'Lunchbox was successfully created.'
27+ redirect_to admin_lunchboxes_path , notice : 'Lunchbox was successfully created.'
2828 else
2929 render :new
3030 end
@@ -51,8 +51,13 @@ def set_lunchbox
5151 @lunchbox = Lunchbox . find ( params [ :id ] )
5252 end
5353
54- # Only allow a trusted parameter "white list" through.
54+ # # Only allow a trusted parameter "white list" through.
55+ # def lunchbox_params
56+ # params.fetch(:lunchbox, {})
57+ # end
58+
5559 def lunchbox_params
56- params . fetch ( :lunchbox , { } )
60+ params . require ( :lunchbox ) . permit ( :name , :price )
5761 end
62+
5863end
Original file line number Diff line number Diff line change 11h1 New lunchbox
22
3- == render ' form'
3+ = form_for(@lunchbox , url: admin_lunchboxes_path) do |f |
4+ - if @lunchbox .errors.any?
5+ #error_explanation
6+ h2 = " #{ pluralize(@lunchbox .errors.count, " error" ) } prohibited this lunchbox from being saved:"
7+ ul
8+ - @lunchbox .errors.full_messages.each do |message |
9+ li = message
410
5- = link_to ' Back' , lunchboxes_path
11+ fieldset
12+ .form-group
13+ = f.label :name
14+ = f.text_field :name , class : ' form-control'
15+
16+ .form-group
17+ = f.label :price
18+ = f.text_field :price , class : ' form-control'
19+
20+ .actions = f.submit
21+
22+ / = link_to 'Back', lunchboxes_path
You can’t perform that action at this time.
0 commit comments