Permalink
Browse files

Rails3.1: db migrate: 062_insert_builtin_roles.rb

DEPRECATION WARNING: the use of 'guard_protected_attributes' will be removed from the next minor release of rails,
if you want to bypass mass-assignment security then look into using assign_attributes.

--HG--
branch : rails3-straight-20111021-1
extra : transplant_source : 5Iq%0F%0FE%27%2B-%E5P6%F5%C5%F0%B5xI%17%C7
  • Loading branch information...
Toshi MARUYAMA
Toshi MARUYAMA committed Oct 11, 2011
1 parent 3acb116 commit c2152b49131b7c59dca6aa0e0a128e2f25eeb013
Showing with 5 additions and 2 deletions.
  1. +5 −2 db/migrate/062_insert_builtin_roles.rb
@@ -1,11 +1,14 @@
class InsertBuiltinRoles < ActiveRecord::Migration
def self.up
+ # rails doesn't know about the previously created builtin attribute without this
+ Role.reset_column_information
+
nonmember = Role.new(:name => 'Non member', :position => 0)
- nonmember.send(:attributes=, { :builtin => Role::BUILTIN_NON_MEMBER }, false)
+ nonmember.assign_attributes({ :builtin => Role::BUILTIN_NON_MEMBER }, :without_protection => true )
nonmember.save
anonymous = Role.new(:name => 'Anonymous', :position => 0)
- anonymous.send(:attributes=, { :builtin => Role::BUILTIN_ANONYMOUS }, false)
+ anonymous.assign_attributes({ :builtin => Role::BUILTIN_ANONYMOUS }, :without_protection => true )
anonymous.save
end

0 comments on commit c2152b4

Please sign in to comment.