Changing UserRole to UserRoleJoin

Beware, this breaks the view for some reason
This commit is contained in:
Jason Denney
2013-04-23 23:21:17 -04:00
parent a3fcdec10c
commit 91bb2ea43e
17 changed files with 100 additions and 37 deletions
@@ -0,0 +1,9 @@
class AlterUserRoles < ActiveRecord::Migration
def change
rename_table :user_roles, :user_role_joins
change_table :user_role_joins do |t|
t.rename :role, :role_id
t.remove :id
end
end
end
+8
View File
@@ -0,0 +1,8 @@
class AddRoles < ActiveRecord::Migration
def change
create_table(:roles) do |t|
t.string :role
t.timestamps
end
end
end
+5
View File
@@ -0,0 +1,5 @@
class AlterUser < ActiveRecord::Migration
def change
remove_column :users, :user_role_id
end
end
+9 -4
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130419010051) do
ActiveRecord::Schema.define(:version => 20130424005701) do
create_table "bike_actions", :force => true do |t|
t.string "action", :limit => 128, :null => false
@@ -97,6 +97,12 @@ ActiveRecord::Schema.define(:version => 20130419010051) do
add_index "logs", ["loggable_id", "loggable_type", "context"], :name => "index_logs_on_loggable_id_and_loggable_type_and_context"
create_table "roles", :force => true do |t|
t.string "role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "task_lists", :force => true do |t|
t.integer "item_id", :null => false
t.string "item_type", :null => false
@@ -148,8 +154,8 @@ ActiveRecord::Schema.define(:version => 20130419010051) do
t.datetime "updated_at", :null => false
end
create_table "user_roles", :force => true do |t|
t.string "role"
create_table "user_role_joins", :id => false, :force => true do |t|
t.string "role_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "ends"
@@ -167,7 +173,6 @@ ActiveRecord::Schema.define(:version => 20130419010051) do
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "user_role_id", :default => 1, :null => false
t.integer "bike_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+9
View File
@@ -0,0 +1,9 @@
user:
id: 1
role: user
staff:
id: 2
role: staff
admin:
id: 3
role: admin
+1 -1
View File
@@ -21,7 +21,7 @@ end
if Rails.env.development?
#create default admin user
if UserRole.all.empty? and User.all.empty?
if User.all.empty?
FactoryGirl.create(:user)
FactoryGirl.create(:staff)
FactoryGirl.create(:admin)