001: Image Uploading with the Paperclip Gem

Mackenzie Child · 59K views · 2014 · 10:10

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they followed when setting up Paperclip, usually while asking how to fix errors they hit partway through.

Recommended by 2 people across 2 different months, 2015 to 2018.

What it is

A 10-minute Rails tutorial by Mackenzie Child that walks through setting up image uploading in a Rails app with the Paperclip gem. It covers installing ImageMagick and the gem, configuring the model, and displaying uploaded images in views.

What people said

Recommends Brendon Baughn · 2015-09 · Stack Overflow · on “undefined method `image' in my view”

I've only been on Rails for a month or so, and I don't know _traverse_ `@posts` for `image`, to be honest.... plus, I'm trying to learn this from mackenziechild [this video]

Recommends MSC · 2018-08 · Stack Overflow · on “Add images into rails article”

There is actually quite a bit of work involved with this: If you need to allow your users to upload images from their computer, you will need to get your head around the Paperclip gem [LINK] (or similar). This will store the image on the server. You'll want to determine how big can images be, what to name the images once uploaded and what file formats are permitted to prevent users uploading all sorts of files. Next on the front-end, you can either use a rich text editor (eg. CKEditor [LINK] or TinyMCE [LINK] are the main ones) to embed the IMG tag(s) into your Article text, or structure that layout yourself (eg. "Always display an image before/after the article text"). Do your images need c

Cites user2498890 · 2015-02 · Stack Overflow · on “Returned error when trying to install Paperclip gem - Ruby-on-Rails”

I'm going through a [this video] to install the Paperclip gem on my site. Got to the last step but its returning the following error, not sure where I'm going wrong.. Error - NoMethodError in Houses#index undefined method `image' for nil:NilClass <%= image_tag @house.image.url(:medium) %> When it comes to including the code to display the image in my index.html.erb so I've put in: <%= image_tag @house.image.url(:medium) %> as the tutorial instructed but its doesn't like that & returns an error when I've uploaded the image and refreshed my index page to view the image. Does anybody have any idea where I'm going wrong? All relevant code is as follows: index.html.erb - <h2><%= link_to "Add a House",

Cites user2498890 · 2015-02 · Stack Overflow · on “Trying to add the Paperclip gem to rails project”

I'm following a video tutorial [this video] to set the Paperclip gem up on my rails project. So the steps I've taken so far.. Installed ImageMagick on Terminal - brew install imagemagick Installed the Paperclip gem - gem "paperclip", "~> 4.2" Added the following to my house.rb model file: has_attached_file :image, styles: { large: "600x600", medium: "300x300", thumb: "150x150#" } validates_attachment_content_type :image, content_type: /\Aimage/.*\Z/ So all in all my house.rb model file now looks like this: class House < ActiveRecord::Base validates :title, presence: true validates :price, presence: true validates :description, presence: true validates :image, presence: true has_attached_file :ima

Cites Alex · 2015-04 · Stack Overflow · on “Paperclip doesn't insert image to database (Rails 4 + Paperclip 4.2.1)”

When I'm trying to upload image to database via paperclip, it always ignore the image column. I'm not sure why it doesn't work, I did lots of research about the paperclip, e.g. github [LINK] , [this video] and did exactly the same as those tutorials. I think I did all of the code correct, but I don't know where the problem comes from, please point that out. the console information Started POST "/categories" for 127.0.0.1 at 2015-04-13 17:07:49 +1000 Processing by CategoriesController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"DIR1d3lWrcwcylkelLsRm/262BRZqu5w3cmrMP/5LV0=", "category"=>{"name"=>"Food", "parent_category_id"=>"", "description"=>""}, "commit"=>"Create Category"} (

Cites Pankaj Yadav · 2017-04 · Stack Overflow · on “Error using paperclip gem in ruby on rails”

I wanted to upload image (using paperclip gem) to my product in my rails project, so i watched a youtube video how to do it ( [this video] ) I did all he did, but i when i add a new product i get an error - 'New Product 2 errors prohibited this product from being saved: Img url Paperclip::Errors::NotIdentifiedByImageMagickError Img url has contents that are not what they are reported to be' , right above my new product form how do i fix it. MY PRODUCT MODEL class Product < ActiveRecord::Base belongs_to :user has_many :taggings, dependent: :destroy has_many :tags, through: :taggings has_attached_file :img_url, styles: { large: "800x600>", medium: "320x200>", thumb: "100x80#" } validates_attachment