Skip to content

Instantly share code, notes, and snippets.

@benmacleod
Last active December 28, 2015 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmacleod/7442338 to your computer and use it in GitHub Desktop.
Save benmacleod/7442338 to your computer and use it in GitHub Desktop.
<%= simple_form_for @item do |i| %>
<%= i.input :name %>
<%= i.input :description %>
<%= i.input :price %>
<%= i.input :zip %>
<%= i.input :weight %>
<%= i.input :volume %>
<%= i.simple_fields_for :item_images do |image| %>
<% image.input :image, as: :file %>
<% end %>
<%= i.submit 'Submit', :class => 'button submit' %>
<% end %>
Unpermitted parameters: item_images
class ItemsController < ApplicationController
def update
@item = current_account.items.find(params[:id])
if @item.update(item_params)
render :edit
else
render :edit
end
end
def item_params
params.require(:item).permit(:name, :description, :price, :zip, :volume, :weight, item_images: {})
end
end
Parameters: {"utf8"=>"✓", "authenticity_token"=>"6oWxcCd4mbuZUQwdq3CXlNNLxrEUnjyP78kEU4OOwFQ=", "item"=>{"name"=>"arstarst", "description"=>"tsra", "price"=>"1.00", "zip"=>"123", "weight"=>"321.00", "volume"=>"123.00", "item_images"=>{"image"=>#
<ActionDispatch::Http::UploadedFile:0x007fd0c4d3f580 @tempfile=#<Tempfile:/var/folders/f5/ygvtnd1j25n5rkt1xqmmrsnm0000gn/T/RackMultipart20131112-65440-2ff3nc>, @original_filename="cute.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"item
[item_images][image]\"; filename=\"cute.jpg\"\r\nContent-Type: image/jpeg\r\n">}}, "commit"=>"Submit", "subdomain"=>"connect", "id"=>"7a87e70b-e04a-4f31-b5b4-c24595aeaf20"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment