Last active
December 28, 2015 04:29
-
-
Save benmacleod/7442338 to your computer and use it in GitHub Desktop.
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
| <%= 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 %> |
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
| Unpermitted parameters: item_images |
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 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 |
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
| 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