Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5.1 migration incompatibility #949

Closed
travisp opened this issue Apr 9, 2017 · 4 comments
Closed

Rails 5.1 migration incompatibility #949

travisp opened this issue Apr 9, 2017 · 4 comments

Comments

@travisp
Copy link

travisp commented Apr 9, 2017

In the Rails 5.1 rc1, the migrations created by PaperTrail 7.0.0 do not work and cause this error:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for

The migration has to be updated from

class CreateVersions < ActiveRecord::Migration

to something like:

 class CreateVersions < ActiveRecord::Migration[4.2]

It appears that this is still the case in the master branch of PaperTrail

@jaredbeck
Copy link
Member

jaredbeck commented Apr 9, 2017

Thanks Travis, that makes sense. How can we change our "migration template" (paper_trail/templates/create_versions.rb) to output the user's rails version?

@jaredbeck
Copy link
Member

It looks like devise uses erb to accomplish this.

https://github.com/plataformatec/devise/blob/master/lib/generators/active_record/templates/migration.rb

I don't know if that's an option for us, but it's one thing we could look into.

jaredbeck added a commit that referenced this issue Apr 10, 2017
e.g. `ActiveRecord::Migration[5.1]`

Fixes #949

Following the example of the devise gem, use erb. In addition, add
the `.erb` file extension to fix syntax highlighting in editor.

Deletes create_versions_spec.rb because the file is no longer valid
ruby so those tests will have to be re-written. We can either
generate a valid ruby file and continue to use similar assertions,
or we can convert those features to use erb, which will have the
benefit of cleaner generated files.
@jaredbeck
Copy link
Member

Closed by #950. Will release in 7.0.1. Thanks Travis.

@dfherr
Copy link

dfherr commented May 31, 2017

i was actually running 7.0.2. At least this is what my gemfile lock says:

  paper_trail (7.0.2)
    activerecord (>= 4.0, < 5.2)
    request_store (~> 1.1)

aried3r pushed a commit to aried3r/paper_trail that referenced this issue Dec 14, 2020
e.g. `ActiveRecord::Migration[5.1]`

Fixes paper-trail-gem#949

Following the example of the devise gem, use erb. In addition, add
the `.erb` file extension to fix syntax highlighting in editor.

Deletes create_versions_spec.rb because the file is no longer valid
ruby so those tests will have to be re-written. We can either
generate a valid ruby file and continue to use similar assertions,
or we can convert those features to use erb, which will have the
benefit of cleaner generated files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants