rails / protected_attributes

Protect attributes from mass-assignment in ActiveRecord models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Rails 5] unable to insert on db migrate

marutosi opened this issue · comments

Work on Rails 4, but not work on Rails 5.

https://bitbucket.org/marutosi/rails5-sandbox/src/1225062885/db/migrate/001_setup.rb#cl-18

class Setup < ActiveRecord::Migration
  # model removed
  class Permission < ActiveRecord::Base
    attr_protected :id
  end

  def self.up
    create_table "permissions", :force => true do |t|
      t.column "controller", :string, :limit => 30, :default => "", :null => false
    end

    Permission.create :controller => "projects"
  end

  def self.down
  end
end
$ rake db:migrate RAILS_ENV=test
== 1 Setup: migrating =========================================================
-- create_table("permissions", {:force=>true})
   -> 0.0044s
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (2 for 0..1)/home/xxx/.rvm/gems/ruby-2.2.2/bundler/gems/rails-fcc46833a88c/activerecord/lib/active_record/core.rb:295:in `initialize'
/home/xxx/.rvm/gems/ruby-2.2.2/bundler/gems/rails-fcc46833a88c/activerecord/lib/active_record/inheritance.rb:61:in `new'
/home/xxx/.rvm/gems/ruby-2.2.2/bundler/gems/rails-fcc46833a88c/activerecord/lib/active_record/inheritance.rb:61:in `new'
/home/xxx/.rvm/gems/ruby-2.2.2/bundler/gems/protected_attributes-95c8eb506276/lib/active_record/mass_assignment_security/persistence.rb:45:in `create'
/REDMINE/hg-workdir/homuhomu/db/migrate/001_setup.rb:29:in `up'

Thank you for the issue. This gem will not be supported on Rails 5.