浏览代码

Added support for Rails 5.1

Andrew Kane 7 年之前
父节点
当前提交
a3d91b0c90
共有 3 个文件被更改,包括 12 次插入2 次删除
  1. 4 0
      CHANGELOG.md
  2. 7 1
      lib/generators/blazer/install_generator.rb
  3. 1 1
      lib/generators/blazer/templates/install.rb

+ 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