Upload image using paperclip in Rails

Improved version of this post has been moved to http://www.ganeshkunwar.com.np/2018/01/27/rails-tutorial-upload-image-using-paperclip-gem/

Please check.


12 thoughts on “Upload image using paperclip in Rails

  1. Nice post. Can you please tell me how to change file upload directory when we use paperclip gem for file uploading…

  2. Please help….I am getting error like undefined method `attr_accessible’ for # while uploading image…..

    1. did you get the answer of your question? If yes then please tell me the answer because i am also having the same issue.
      Thanks in advance

  3. thank you Ganesh Kunwar for this nice tutorial..
    add following codes in image.rb MODEL.
    validates_attachment_file_name :image, :matches => [/png\Z/, /jpe?g\Z/, /gif\Z/]

    and In controller add method
    def image_params

    adding this you may not mention attr_accessible :image in MODEL image.rb
    this will work in rails 4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s