Skip to content

Commit

Permalink
Fix generator for older (pre-7) rails version
Browse files Browse the repository at this point in the history
  • Loading branch information
fschwahn committed Feb 19, 2024
1 parent 6a766e5 commit a589fee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/generators/shortener/shortener_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.source_root
end

def self.next_migration_number(dirname)
if ActiveRecord.timestamped_migrations
if ActiveRecord.respond_to?(:timestamped_migrations) ? ActiveRecord.timestamped_migrations : ActiveRecord::Base.timestamped_migrations
Time.new.utc.strftime("%Y%m%d%H%M%S")
else
"%.3d" % (current_migration_number(dirname) + 1)
Expand Down

2 comments on commit a589fee

@claudiotrindade
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/gems/activerecord-7.1.2/lib/active_record/dynamic_matchers.rb:22:in method_missing': undefined method timestamped_migrations' for ActiveRecord::Base:Class (NoMethodError)

@fschwahn
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claudiotrindade this is not released in a gem yet, so if you see that error you have to point in your Gemfile to this repo.

Please sign in to comment.