Created role model

This commit is contained in:
2013-01-28 00:18:36 -05:00
parent d9e9814823
commit b3177c8889
6 changed files with 39 additions and 1 deletions

3
app/models/role.rb Normal file
View File

@@ -0,0 +1,3 @@
class Role < ActiveRecord::Base
attr_accessible :name
end

View File

@@ -0,0 +1,9 @@
class CreateRoles < ActiveRecord::Migration
def change
create_table :roles do |t|
t.string :name
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddRoleIdToUser < ActiveRecord::Migration
def change
add_column :users, :role_id, :integer
end
end

View File

@@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130114162614) do ActiveRecord::Schema.define(:version => 20130128051658) do
create_table "categories", :force => true do |t| create_table "categories", :force => true do |t|
t.string "title" t.string "title"
@@ -42,6 +42,12 @@ ActiveRecord::Schema.define(:version => 20130114162614) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "roles", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "topics", :force => true do |t| create_table "topics", :force => true do |t|
t.string "title" t.string "title"
t.integer "hits", :default => 0 t.integer "hits", :default => 0
@@ -71,6 +77,7 @@ ActiveRecord::Schema.define(:version => 20130114162614) do
t.integer "posts_count", :default => 0 t.integer "posts_count", :default => 0
t.string "username" t.string "username"
t.boolean "is_admin" t.boolean "is_admin"
t.integer "role_id"
end end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true

7
test/fixtures/roles.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
name: MyString
two:
name: MyString

7
test/unit/role_test.rb Normal file
View File

@@ -0,0 +1,7 @@
require 'test_helper'
class RoleTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end