I'm building a site where users will be able to upload multiple pictures, so decided to use paperclip. Implemented following the Railscast, and browse field shows up on page but when I create (or edit) a user, I get an error that says photo must be set. Any ideas what I'm doing wrong?
user.rb:
new.html.erb:Code:class User < ActiveRecord::Base validates_presence_of :fname, :lname, :city, :country, :email, :confirm has_many :photos has_attached_file :photo, :styles => { :small => "200x200>", :thumb=> "100x100>" }, :url => "/images/userpics/:id/:style/:basename.:extension", :path => ":rails_root/public/images/userpics/:id/:style/:basename.:extension" validates_attachment_presence :photo validates_attachment_size :photo, :less_than => 5.megabytes validates_attachment_content_type :photo, :content_type => ['image/gif', 'image/png', 'image/x-png', 'image/jpeg', 'image/pjpeg', 'image/jpg'] end
show.html.erb:Code:<h3>Create Your Account</h3> <% form_for @album, :html => { :multipart => true } do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <%= f.error_messages %> <p> <%= f.label :fname %><br /> <%= f.text_field :fname %> </p> ...
Code:<h2>Edit Your Profile <%= @user.fname %></h2> <%= image_tag @user.photo.url(:thumb) %> <p> <b>First:</b> <%=h @user.fname %> </p> <p> <b>Last:</b> <%=h @user.lname %> </p> <p> <b>City:</b> <%=h @user.city %> </p>




Bookmarks