I carefully followed the docs https://github.com/thoughtbot/paperclip to install the paperclip implementation in my image upload application. I am currently using gem 'paperclip', '~> 5.0.0.beta1'. After I migrated, four columns were correctly added to my schema:
t.string "picture_file_name"
t.string "picture_content_type"
t.integer "picture_file_size"
t.datetime "picture_updated_at"
Therefore, my paper clip must be installed correctly. However, when I started adding the following two lines to my model class:
has_attached_file :picture, styles: { medium: "300*300>", thumb: "100*100" }, default_url: "/images/start_project3.jpg"
validates_attachment_content_type :picture, content_type: /\Aimage\/.*\Z/
Everything is broken. I'm trying to create, search, or anything related to a model class in the rails console, it yells at me with the following error:
NoMethodError: undefined method `has_attached_file' for #<Class:0x0055bd71ec0228>
paperclip 4.3.0 paperclip, . , . , :
class AddAttachmentPictureToProjects < ActiveRecord::Migration
def self.up
change_table :projects do |t|
t.attachment :picture
end
end
def self.down
remove_attachment :projects, :picture
end
end
, .
gem:
source 'https://rubygems.org'
gem 'rails', '4.2.7.1'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'
gem 'pry-rails'
gem 'annotate'
gem 'faker'
gem 'pg_search'
gem 'paperclip', '~> 5.0.0.beta1'
group :development, :test do
gem 'byebug'
gem 'faker'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :production do
gem 'newrelic_rpm'
gem 'rails_12factor'
end