Permalink
Browse files

more on setting up infrastructure

  • Loading branch information...
1 parent 7917c0d commit 1d3ff0e0ad70b372909cc307747deff05531da37 @stanislaw committed Sep 2, 2011
View
@@ -12,7 +12,7 @@ gem 'rake-kit'
gem 'require_all'
gem 'sugar-high'
-
+gem 'sweetloader'
group :development, :test do
gem 'cutter'
end
View
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end
-APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
+APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
View
@@ -0,0 +1,4 @@
+class Role < ActiveRecord::Base
+ has_many :user_roles
+ has_many :users, :through => :user_roles
+end
View
@@ -0,0 +1,6 @@
+class User < ActiveRecord::Base
+ serialize :roles
+
+ has_many :user_roles
+ has_many :roles, :through => :user_roles
+end
View
@@ -0,0 +1,4 @@
+class UserRole
+ belongs_to :user
+ belongs_to :role
+end
@@ -0,0 +1,15 @@
+class CreateUserRoles < ActiveRecord::Migration
+ def up
+ create_table :user_roles do |t|
+ t.integer :user_id
+ t.integer :role_id
+
+ t.timestamps
+ end
+ add_index :user_roles, [:user_id, :role_id]
+ end
+
+ def down
+ drop_table :user_roles
+ end
+end
@@ -0,0 +1,12 @@
+class CreateRoles < ActiveRecord::Migration
+ def up
+ create_table :roles do |t|
+ t.string :name
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :roles
+ end
+end
View
@@ -1,4 +1,5 @@
require "simple_roles/engine"
-
+require "sweetloader"
module SimpleRoles
+ autoload_modules :Base
end
View
@@ -0,0 +1,13 @@
+module SimpleRoles
+ module Base
+
+ def roles_list
+ roles
+ end
+
+ def role_groups_list
+ role_groups
+ end
+
+ end
+end
View
@@ -3,4 +3,4 @@
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_PATH = File.expand_path('../..', __FILE__)
-load File.expand_path('../../test/dummy/script/rails', __FILE__)
+load File.expand_path('../../spec/dummy/script/rails', __FILE__)
@@ -0,0 +1,15 @@
+class CreateUserRoles < ActiveRecord::Migration
+ def up
+ create_table :user_roles do |t|
+ t.integer :user_id
+ t.integer :role_id
+
+ t.timestamps
+ end
+ add_index :user_roles, [:user_id, :role_id]
+ end
+
+ def down
+ drop_table :user_roles
+ end
+end
@@ -0,0 +1,12 @@
+class CreateRoles < ActiveRecord::Migration
+ def up
+ create_table :roles do |t|
+ t.string :name
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :roles
+ end
+end

0 comments on commit 1d3ff0e

Please sign in to comment.