Note that there are some explanatory texts on larger screens.

plurals
  1. PONew to Rails/paperclip - Paperclip wont save
    primarykey
    data
    text
    <p>I'm very new to programming and I am trying to use paperclip to add a user photo to my user records. Records can be created from the add new record form without the &lt;%= f.file_field :photo %> line and redirects properly and saves the record to the database. However, when its included on save it wants to redirect to create.html.erb instead of the users path and doesn't save the new record. It also doesn't display any errors. I have updated the users table with the photo_file_name, photo_content_type and :photo_file_size fields. Also, I'm running windows if thats any help.</p> <p>Model:</p> <pre><code>class User &lt; ActiveRecord::Base has_many :venues has_many :reviews has_attached_file :photo, :styles =&gt; { :medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" } end </code></pre> <p>Controller:</p> <pre><code>class UsersController &lt; ApplicationController def index @users = User.all end def new @user = User.new end def create @user = User.create(params[:user]) if @user.save flash[:notice] = 'User added' redirect_to users_path else @user.save end end def show @user = User.find(params[:id]) end end </code></pre> <p>View:</p> <pre><code>&lt;% form_for (@user, :html =&gt; { :multipart =&gt; true }) do |f| %&gt; &lt;p&gt;username: &lt;br&gt; &lt;%= f.text_field :username %&gt;&lt;/p&gt; &lt;p&gt;password: &lt;br&gt; &lt;%= f.text_field :password %&gt;&lt;/p&gt; &lt;p&gt;photo: &lt;br&gt; &lt;%= f.file_field :photo %&gt;&lt;/p&gt; &lt;%= submit_tag %&gt; &lt;% end %&gt; </code></pre> <p>Any help is much appreciated!</p> <p>Whats shown in the development log:</p> <blockquote> <p>Processing UsersController#create (for 127.0.0.1 at 2011-01-12 22:05:56) [POST] Parameters: {"user"=>{"photo"=>#, "username"=>"nghjhg", "password"=>"ghjghj"}, "commit"=>"Save changes", "authenticity_token"=>"IlacpnqsC/iJ+41bx8tN4obOWPgirMx810l/WvohN68="} [paperclip] identify -format %wx%h "C:/Users/Home/AppData/Local/Temp/stream110112-5292-2yorcw-0.png[0]" 2>NUL [paperclip] An error was received while processing:</p> <p>C:/Users/Home/AppData/Local/Temp/stream110112-5292-2yorcw-0.png is not recognized by the 'identify' command.> [paperclip] identify -format %wx%h "C:/Users/Home/AppData/Local/Temp/stream110112-5292-2yorcw-0.png[0]" 2>NUL [paperclip] An error was received while processing:</p> <p>C:/Users/Home/AppData/Local/Temp/stream110112-5292-2yorcw-0.png is not recognized by the 'identify' command.> Rendering template within layouts/application Rendering users/create Completed in 157ms (View: 4, DB: 0) | 200 OK [http://localhost/users]</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload