diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index e86ee4e..49d3848 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -31,4 +31,8 @@ def update_new_user user, new_user_hash redirect_to new_admin_user_path end end + + def user_params + params.require(:user).permit() + end end \ No newline at end of file diff --git a/app/models/role.rb b/app/models/role.rb index 4828b44..be852c3 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,4 +1,4 @@ class Role < ActiveRecord::Base - has_and_belongs_to_many :users + has_many :users has_and_belongs_to_many :permissions end diff --git a/app/models/user.rb b/app/models/user.rb index 0664d26..4f5bf64 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,9 @@ class User < ActiveRecord::Base - has_and_belongs_to_many :roles, :skills, :jobs + has_many :skills + has_and_belongs_to_many :jobs has_many :permissions, :through => :roles has_one :resume, :foreign_key => :owner_id + has_one :role accepts_nested_attributes_for :roles accepts_nested_attributes_for :skills @@ -16,7 +18,7 @@ class User < ActiveRecord::Base validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } - VALID_PHONE_REGEX = /^(\([0-9]{3}\) |[0-9]{3}-|[0-9]{3})[0-9]{3}-[0-9]{4}$/ + VALID_PHONE_REGEX = /(\([0-9]{3}\) |[0-9]{3}-|[0-9]{3})[0-9]{3}-[0-9]{4}/ validates :phone, format: { with: VALID_PHONE_REGEX } @@ -35,4 +37,4 @@ def is_admin? def can_post? self.has_permission? "can_post" end -end \ No newline at end of file +end diff --git a/db/migrate/20140921055840_jobs_tags.rb b/db/migrate/20140921055840_jobs_tags.rb index 3e8f39d..e8c40a4 100644 --- a/db/migrate/20140921055840_jobs_tags.rb +++ b/db/migrate/20140921055840_jobs_tags.rb @@ -1,6 +1,6 @@ class JobsTags < ActiveRecord::Migration def up - create table :jobs_tags, :id=>false do |t| + create_table :jobs_tags, :id=>false do |t| t.integer :job_id t.integer :tag_id end diff --git a/db/migrate/20140921074109_users_skills.rb b/db/migrate/20140921074109_users_skills.rb index 0cb5db0..8afd9f2 100644 --- a/db/migrate/20140921074109_users_skills.rb +++ b/db/migrate/20140921074109_users_skills.rb @@ -1,6 +1,6 @@ class UsersSkills < ActiveRecord::Migration def up - create table :users_skills, :id=>false do |t| + create_table :users_skills, :id=>false do |t| t.integer :user_id t.integer :skill_id end diff --git a/db/schema.rb b/db/schema.rb index 0483e9b..f41faa0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,58 +9,91 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130619173956) do +ActiveRecord::Schema.define(version: 20140921074109) do - create_table "permissions", :force => true do |t| + create_table "categories", force: true do |t| t.string "name" end - create_table "permissions_roles", :id => false, :force => true do |t| + create_table "jobs", force: true do |t| + t.integer "owner_id" + t.string "title" + t.string "description" + t.integer "salary" + t.string "location" + t.integer "category_id" + t.datetime "deadline" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "jobs_tags", id: false, force: true do |t| + t.integer "job_id" + t.integer "tag_id" + end + + create_table "permissions", force: true do |t| + t.string "name" + end + + create_table "permissions_roles", id: false, force: true do |t| t.integer "permission_id" t.string "role_id" end - create_table "posts", :force => true do |t| - t.integer "owner_id" - t.text "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "draft" + create_table "resumes", force: true do |t| + t.string "title" + t.string "body" + t.integer "owner_id" end - create_table "roles", :force => true do |t| + create_table "roles", force: true do |t| t.string "name" end - create_table "roles_users", :id => false, :force => true do |t| + create_table "roles_users", id: false, force: true do |t| t.integer "role_id" t.string "user_id" end - add_index "roles_users", ["role_id"], :name => "index_roles_users_on_role_id" - add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" + add_index "roles_users", ["role_id"], name: "index_roles_users_on_role_id", using: :btree + add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id", using: :btree + + create_table "skills", force: true do |t| + t.string "name" + t.integer "users_id" + end + + create_table "tags", force: true do |t| + t.string "name" + end - create_table "users", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :default => "", :null => false + create_table "users", force: true do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.string "phone" t.string "username" t.string "name" end - add_index "users", ["email"], :name => "index_users_on_email", :unique => true - add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + + create_table "users_skills", id: false, force: true do |t| + t.integer "user_id" + t.integer "skill_id" + end end