Skip to content

Commit

Permalink
Some changes to get the migrations working correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanil Puri committed Sep 22, 2014
1 parent ed29293 commit 46614c3
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 29 deletions.
4 changes: 4 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/models/role.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Role < ActiveRecord::Base
has_and_belongs_to_many :users
has_many :users
has_and_belongs_to_many :permissions
end
8 changes: 5 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }

Expand All @@ -35,4 +37,4 @@ def is_admin?
def can_post?
self.has_permission? "can_post"
end
end
end
2 changes: 1 addition & 1 deletion db/migrate/20140921055840_jobs_tags.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20140921074109_users_skills.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
79 changes: 56 additions & 23 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 46614c3

Please sign in to comment.