Created role model
This commit is contained in:
3
app/models/role.rb
Normal file
3
app/models/role.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class Role < ActiveRecord::Base
|
||||||
|
attr_accessible :name
|
||||||
|
end
|
||||||
9
db/migrate/20130128051640_create_roles.rb
Normal file
9
db/migrate/20130128051640_create_roles.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class CreateRoles < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :roles do |t|
|
||||||
|
t.string :name
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20130128051658_add_role_id_to_user.rb
Normal file
5
db/migrate/20130128051658_add_role_id_to_user.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddRoleIdToUser < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :role_id, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -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
7
test/fixtures/roles.yml
vendored
Normal 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
7
test/unit/role_test.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class RoleTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user