Reputation: 1566
I'm following a video tutorial to set the Paperclip gem up on my rails project.
So the steps I've taken so far..
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 :image, styles: { large: "600x600", medium: "300x300", thumb: "150x150#" }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
end
At which point I need to add a migration using the migration generator, so I type in rails g migration house image and it isn't creating a timestamped database migration file in the folder and the terminal is returning:
Usage:
rails new APP_PATH [options]
and a whole bunch of options. In the tutorial it should return something like:
create db/migrate/20150205123408_add_attachment_image_to_posts.rb
I'm not sure where I'm going wrong here and I'm new to ruby-on-rails so any help would be really appreciated!
Upvotes: 0
Views: 82
Reputation: 1650
If problem persist, create the migration manually.
create_table "media", force: :cascade do |t|
t.string "image_video_file_name"
t.string "image_video_content_type"
t.integer "image_video_file_size"
t.datetime "image_video_updated_at"
t.string "text", default: ""
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id", null: false
end
add_index "media", ["user_id"], name: "index_media_on_user_id", using: :btree
Upvotes: 0