Sha256: 95f77d17408abeec7bccc750675175f05a9b938d0f07378f56f8e2703dd9f675

Contents?: true

Size: 1005 Bytes

Versions: 3

Compression:

Stored size: 1005 Bytes

Contents

# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)

puts 'SETTING UP ROLES...'
roles = [ 
  {:name => "Member"},
  {:name => "Admin"}
]

roles.each do |attributes| 
  Citygate::Role.find_or_initialize_by_name(attributes[:name]).save!
end

puts 'Creating permissions for citygate...'
permissions = [
  # Guest
  {:action => "index", :subject_class => "home", :role_id => nil },
  # Member
  {:action => "read", :subject_class => "Citygate::User", :role_id => 1 },
  # Admin
  {:action => "manage", :subject_class => "all", :role_id => 2 }
]

permissions.each do |attributes| 
  Citygate::Permission.create attributes
end unless Citygate::Permission.find_by_action_and_subject_class_and_role_id("index","home",nil)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
citygate-0.0.9 db/seeds.rb
citygate-0.0.8 db/seeds.rb
citygate-0.0.7 db/seeds.rb