Hello, every time I give the migration it throws me an error and it does not let me do the migration.
gem "paperclip", "~> 5.0.0"
gem "spring", group: :development
the gems that I have installed.
What the error says is that you must specify in your migrations the version of Rails with which you are working; You do this by adding the bracketed version directly in the class you inherit from ActiveRecord::Migration
; for example, the error message shows how it would be done for Rails 4.2
:
class AddAttachmentAvatarToProductossnack < ActiveRecord::Migration[4.2]
...
end
In your case, that you are using version 5.1.1
then you would do the following:
class AddAttachmentAvatarToProductossnack < ActiveRecord::Migration[5.1]
...
end
The file you must edit is: db / migrate / 20170822195101_add_attachment_avatar_to_productossnack.rb ; which was generated when you executed the command:
$ rails generate paperclip productosnack avatar
I still can not comment but helping you with your comment in the previous question would be the way to build the migration in this way.
class AddAttachmentAvatarToProductossnack < ActiveRecord::Migration[5.1]
def up
add_attachment :productossnack, :avatar
end
def down
remove_attachment :productossnack, :avatar
end
end
Command:
rails g migration AddAttachmentAvatarToProductossnack