Created
October 17, 2014 16:39
-
-
Save jaake/186d55b13d1ed4bb549b to your computer and use it in GitHub Desktop.
update problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| VIEW: | |
| <% @foods.each do |panel| %> | |
| <%= form_for panel do |f| %> | |
| <div class='menu_edit'> | |
| <div class="field"> | |
| <h2><%= f.text_field :title %></h2> | |
| </div> | |
| <div class="field"> | |
| <h3><%= f.text_field :item01 %></h3> | |
| </div> | |
| <div class="field"> | |
| <p><%= f.text_field :notes01 %></p> | |
| </div> | |
| <div class="field"> | |
| <h3><%= f.text_field :item02 %></h3> | |
| </div> | |
| <div class="field"> | |
| <p><%= f.text_field :notes02 %></p> | |
| </div> | |
| <div class="field"> | |
| <h3><%= f.text_field :item03 %></h3> | |
| </div> | |
| <div class="field"> | |
| <p><%= f.text_field :notes03 %></p> | |
| </div> | |
| <div class="field"> | |
| <h3><%= f.text_field :item04 %></h3> | |
| </div> | |
| <div class="field"> | |
| <p><%= f.text_field :notes04 %></p> | |
| </div> | |
| <div class="field"> | |
| <h3><%= f.text_field :item05 %></h3> | |
| </div> | |
| <div class="field"> | |
| <p><%= f.text_field :notes05 %></p> | |
| </div> | |
| <div class="actions"><%= f.submit "update" %></div> | |
| </div> | |
| <% end %> | |
| <% end %> | |
| CONTROLLER: | |
| class FoodPanelsController < ApplicationController | |
| before_filter :authorize, only: [:update] | |
| def update | |
| if FoodPanel.find(params[:id]) | |
| panel = FoodPanel.find(params[:id]) | |
| panel.title = params[:food_panel][:title] | |
| panel.item01 = params[:food_panel][:item01] | |
| panel.notes01 = params[:food_panel][:notes01] | |
| panel.item01 = params[:food_panel][:item02] | |
| panel.notes01 = params[:food_panel][:notes02] | |
| panel.item01 = params[:food_panel][:item03] | |
| panel.notes01 = params[:food_panel][:notes03] | |
| panel.item01 = params[:food_panel][:item04] | |
| panel.notes01 = params[:food_panel][:notes04] | |
| panel.item01 = params[:food_panel][:item05] | |
| panel.notes01 = params[:food_panel][:notes05] | |
| panel.save | |
| redirect_to root_url | |
| flash[:notice] = "Menu has been updated." | |
| else | |
| render "edit" | |
| flash[:notice] = "Wrong" | |
| end | |
| end | |
| private | |
| # not currently in use | |
| def food_params | |
| params[:food_panel].require(:title).permit(:item01, :notes01, :item02, :notes02, :item03, :notes03, :item04, :notes04, :item05, :notes05) | |
| end | |
| end | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the log:
Started PATCH "/food_panels/3" for 127.0.0.1 at 2014-10-17 11:35:04 -0500
Processing by FoodPanelsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"ogUgcjpUwTm6cia9/7GkSyx+G4+tF95tothEtbwgbvw=", "food_panel"=>{"title"=>"Breakfast in a Hurry!", "item01"=>"", "notes01"=>"", "item02"=>"Granola & Milk $3.00", "notes02"=>"", "item03"=>"Honey & Oats Granola $5.50", "notes03"=>"12oz hdaskfdhsgfa", "item04"=>"Cranberry & Coconut Granola $6.00", "notes04"=>"12oz", "item05"=>"", "notes05"=>""}, "commit"=>"update", "id"=>"3"}
�[1m�[35mUser Load (0.1ms)�[0m SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
�[1m�[36mFoodPanel Load (0.2ms)�[0m �[1mSELECT "food_panels".* FROM "food_panels" WHERE "food_panels"."id" = ? LIMIT 1�[0m [["id", 3]]
�[1m�[35mCACHE (0.0ms)�[0m SELECT "food_panels".* FROM "food_panels" WHERE "food_panels"."id" = ? LIMIT 1 [["id", "3"]]
�[1m�[36m (0.1ms)�[0m �[1mbegin transaction�[0m
�[1m�[35m (0.1ms)�[0m commit transaction
Redirected to http://localhost/
Completed 302 Found in 6ms (ActiveRecord: 0.6ms)