Created
October 17, 2014 15:36
-
-
Save jaake/fc7cefb58808327e9c30 to your computer and use it in GitHub Desktop.
Understanding ActiveRecord.update
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
| class FoodPanelsController < ApplicationController | |
| before_filter :authorize, only: [:update] | |
| def update | |
| panel = FoodPanel.find(params[:id]) | |
| if panel.update(food_params) | |
| redirect_to root_url | |
| flash[:notice] = "Menu has been updated." | |
| else | |
| render "edit" | |
| flash[:notice] = "Wrong" | |
| end | |
| end | |
| private | |
| def food_params | |
| params.require(:food_panel).permit(:title, :text01, :notes01, :text02, :notes02, :text03, :notes03, :text04, :notes04, :text05, :notes05) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment