Browse Source

Added support for Rails 5.1

Andrew Kane 7 years ago
parent
commit
a3d91b0c90

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+## 1.8.0 [unreleased]
+
+- Added support for Rails 5.1
+
 ## 1.7.10
 
 - Added support for Google BigQuery

+ 7 - 1
lib/generators/blazer/install_generator.rb

@@ -22,12 +22,18 @@ module Blazer
       end
 
       def copy_migration
-        migration_template "install.rb", "db/migrate/install_blazer.rb"
+        migration_template "install.rb", "db/migrate/install_blazer.rb", migration_version: migration_version
       end
 
       def copy_config
         template "config.yml", "config/blazer.yml"
       end
+
+      def migration_version
+        if ActiveRecord::VERSION::MAJOR >= 5
+          "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
+        end
+      end
     end
   end
 end

+ 1 - 1
lib/generators/blazer/templates/install.rb

@@ -1,4 +1,4 @@
-class <%= migration_class_name %> < ActiveRecord::Migration
+class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
   def change
     create_table :blazer_queries do |t|
       t.references :creator