Sha256: 60c4a9feb35da32939f8ddc99a515e3dcabb4acfa0efb21c4f22c1ebae30fa09

Contents?: true

Size: 767 Bytes

Versions: 6

Compression:

Stored size: 767 Bytes

Contents

class Add<%= parsed_right_name.camelize %>Right < ActiveRecord::Migration

  class Right < ActiveRecord::Base
    has_and_belongs_to_many :roles

    validates_presence_of :name
    validates_uniqueness_of :name
  end

  class Role < ActiveRecord::Base
    has_and_belongs_to_many :rights

    validates_presence_of :title
    validates_uniqueness_of :title
  end

  def self.up
    right_for_roles = Right.find_by_name("<%= right_for_roles %>")
    Right.create(
      :controller => '<%= right_controller %>'.presence,
      :action     => '<%= right_action %>'.presence,
      :name       => '<%= right_name %>'.presence,
      :roles      => right_for_roles.roles
    )
  end
  
  
  def self.down
    Right.destroy_all(:name => '<%= right_name %>')
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
right_on-1.0.0 lib/right_on/generators/templates/right_migration.rb
right_on-0.4.1 lib/right_on/generators/templates/right_migration.rb
right_on-0.4.0 lib/right_on/generators/templates/right_migration.rb
right_on-0.3.0 lib/right_on/generators/templates/right_migration.rb
right_on-0.2.0 lib/right_on/generators/templates/right_migration.rb
right_on-0.1.0 lib/right_on/generators/templates/right_migration.rb