Skip to content

Instantly share code, notes, and snippets.

@GantMan
Created October 24, 2012 20:19
Show Gist options
  • Save GantMan/3948594 to your computer and use it in GitHub Desktop.
Save GantMan/3948594 to your computer and use it in GitHub Desktop.
1 class Appetizer < ActiveRecord::Base
2 include ActiveModel::ForbiddenAttributesProtection
3 end
40 # POST /appetizers
41 # POST /appetizers.json
42 def create
43 @appetizer = Appetizer.new(params[:appetizer])
44
45 respond_to do |format|
46 if @appetizer.save
47 format.html { redirect_to @appetizer, notice: 'Appetizer was successfully created.' }
48 format.json { render json: @appetizer, status: :created, location: @appetizer }
49 else
50 format.html { render action: "new" }
51 format.json { render json: @appetizer.errors, status: :unprocessable_entity }
52 end
53 end
54 end
40 # POST /desserts
41 # POST /desserts.json
42 def create
43 @dessert = Dessert.new(dessert_params)
44
45 respond_to do |format|
46 if @dessert.save
47 format.html { redirect_to @dessert, notice: 'Dessert was successfully created.' }
48 format.json { render json: @dessert, status: :created, location: @dessert }
49 else
50 format.html { render action: "new" }
51 format.json { render json: @dessert.errors, status: :unprocessable_entity }
52 end
53 end
54 end
84 private
85
86 # Use this method to whitelist the permissible parameters. Example:
87 # params.require(:person).permit(:name, :age)
88 # Also, you can specialize this method with per-user checking of permissible attributes.
89 def dessert_params
90 params.require(:dessert).permit(:name, :recipe, :title)
91 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment