-
-
Save superlou/3309280 to your computer and use it in GitHub Desktop.
Paperclip Upload "No file chosen" (fixed)
This file contains 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
= semantic_form_for [@space, @map], :html => {:multipart => true} do |f| | |
= f.inputs do | |
= f.input :space_id, :as => :hidden | |
= f.input :image | |
= f.actions |
This file contains 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
Connie::Application.configure do | |
# Settings specified here will take precedence over those in config/application.rb | |
... | |
# Expands the lines which load the assets | |
config.assets.debug = false #true | |
# Paperclip configuration | |
Paperclip.options[:command_path] = "/usr/bin/" | |
end |
This file contains 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
Started POST "/spaces/1/maps" for 127.0.0.1 at 2012-08-09 19:59:07 -0400 | |
Processing by MapsController#create as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"LWOp0AQARd2EzN+ls+DocIXcuexaRQQt8tCMjh+M1QY=", "map"=>{"space_id"=>"1", "imag | |
e"=>#<ActionDispatch::Http::UploadedFile:0x000000031c87e0 @original_filename="cartoon.jpg", @content_type="image/jpeg", @headers | |
="Content-Disposition: form-data; name=\"map[image]\"; filename=\"cartoon.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<Fi | |
le:/tmp/RackMultipart20120809-11699-175s08t>>}, "commit"=>"Create Map", "space_id"=>"1"} |
This file contains 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 Map < ActiveRecord::Base | |
attr_accessible :space_id, :image | |
belongs_to :space | |
has_attached_file :image, | |
:styles => {:medium => "300x300>", | |
:thumb => "100x100>"} | |
validates_attachment_presence :image | |
end |
This file contains 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 MapsController < ApplicationController | |
def new | |
@space = Space.find(params[:space_id]) | |
@map = @space.maps.build | |
end | |
def create | |
@space = Space.find(params[:space_id]) | |
@map = @space.maps.build(params[:map]) # << This was wrongly :space previously | |
if @map.save | |
redirect_to [@space, @map], :notice => "Map created successfully" | |
else | |
render :action => :new | |
end | |
end | |
... |
This file contains 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
... | |
create_table "maps", :force => true do |t| | |
t.integer "space_id" | |
t.datetime "created_at", :null => false | |
t.datetime "updated_at", :null => false | |
t.string "image_file_name" | |
t.string "image_content_type" | |
t.integer "image_file_size" | |
t.datetime "image_updated_at" | |
end | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment