Skip to content

Instantly share code, notes, and snippets.

@jaake
Created October 17, 2014 15:36
Show Gist options
  • Select an option

  • Save jaake/fc7cefb58808327e9c30 to your computer and use it in GitHub Desktop.

Select an option

Save jaake/fc7cefb58808327e9c30 to your computer and use it in GitHub Desktop.
Understanding ActiveRecord.update
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