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 %>
  <div class="field">
   <%= f.label :name %><br />
   <%= f.text_field :name %>
  </div>
  <div class="field">
   <%= f.label :email %><br />
   <%= f.text_field :email %>
  </div>
  <div class="field">
   <%= f.label :password %><br />
   <%= f.password_field :password %>
  </div>
  <div class="field">
   <%= f.label :password_confirmation, "Confirmation" %><br />
   <%= f.password_field :password_confirmation %>
  </div>
  <div class="field">
   <%= f.file_field :avatar %>
  </div>
  <div class="actions">
    <%= f.submit "Sign Up" %>
  </div>

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:
<img alt="Missing" src="/avatars/original/missing.png" />

If I check where the src link goes it gives me:
<h1>Routing Error</h1>
<p><pre>No route matches &quot;/avatars/original/missing.png&quot; with
{:method=&gt;:get}</pre></p>

I really don't know what the problem is. I've been following the Quick
Start guide (from http://github.com/thoughtbot/paperclip) 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.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to