Hello all,
I’m a Rails newbie trying to get a basic implementation of Paperclip up
but it’s giving me problems. I’m developing on Windows XP (I know…)
with WEBrick and MySQL.
In my model I have:
class User < ActiveRecord::Base
has_attached_file :avatar,:styles => { :medium => “300x300>”, :thumb
=> “100x100>” }, :url => “/public/data/”, :path =>
“:rails_root/public/data/”
end
I added the path and URL options because it wasn’t working under the
default at all, same problem. In my view:
<% form_for @user, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= f.text_field :name %>
<%= f.text_field :email %>
<%= f.password_field :password %>
<%= f.password_field :password_confirmation %>
In my controller:
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = “Welcome”
redirect_to @user
else
@user.password = “”
@user.password_confirmation = “”
@title = “Sign Up”
render ‘new’
end
end
When I try to create a new user with an avatar the SQL (from the server
logs) is:
INSERT INTO users
(name
,
email
,
created_at
,
updated_at
,
encrypted_password
,
salt
,
remember_token
,
admin
,
avatar_file_name
,
avatar_content_type
,
avatar_file_size
,
avatar_updated_at
)
VALUES
(‘Example User’,
‘[email protected]’,
‘2010-08-07 00:18:52’,
‘2010-08-07 00:18:52’,
‘e49ab5f50085e13f986e0a89acd3d709131b45c3bb8a74fae69a8b8e58c0fcd3’,
‘90bf715adac888a8d6c88061dbdb9df368eabe7ac2317a432c34c0d48e12defa’,
NULL,
0,
NULL,
NULL,
NULL,
NULL)
When I look at the new user the avatar is replaced by the text “Missing”
and the HTML generated is:
If I check where the src link goes it gives me:
Routing Error
No route matches "/avatars/original/missing.png" with {:method=>:get}
I really don’t know what the problem is. I’ve been following the Quick
Start guide (from GitHub - thoughtbot/paperclip: Easy file attachment management for ActiveRecord) and
cross-referencing from other guides like Railscast, but none of them
seem to help. Sorry this is so long; I’m sure the solution is something
simple I overlooked but I have no idea where.