Changed Roles within the app to FormRole to account for adding Rolify.
This commit is contained in:
parent
a2a9e1312b
commit
65df59d3e6
2
Gemfile
2
Gemfile
|
@ -28,6 +28,8 @@ gem "jbuilder"
|
||||||
|
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
|
|
||||||
|
gem 'rolify'
|
||||||
|
|
||||||
gem 'webpacker'
|
gem 'webpacker'
|
||||||
|
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
|
|
@ -228,6 +228,7 @@ GEM
|
||||||
actionpack (>= 5.2)
|
actionpack (>= 5.2)
|
||||||
railties (>= 5.2)
|
railties (>= 5.2)
|
||||||
rexml (3.2.6)
|
rexml (3.2.6)
|
||||||
|
rolify (6.0.1)
|
||||||
ruby2_keywords (0.0.5)
|
ruby2_keywords (0.0.5)
|
||||||
rubyzip (2.3.2)
|
rubyzip (2.3.2)
|
||||||
selenium-webdriver (4.16.0)
|
selenium-webdriver (4.16.0)
|
||||||
|
@ -298,6 +299,7 @@ DEPENDENCIES
|
||||||
kaminari
|
kaminari
|
||||||
puma (>= 5.0)
|
puma (>= 5.0)
|
||||||
rails (~> 7.1.2)
|
rails (~> 7.1.2)
|
||||||
|
rolify
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
sqlite3 (~> 1.4)
|
sqlite3 (~> 1.4)
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -38,6 +38,11 @@ reset:
|
||||||
# bundle install
|
# bundle install
|
||||||
# rails g kaminari:views default
|
# rails g kaminari:views default
|
||||||
|
|
||||||
|
# gem 'rolify'
|
||||||
|
# bundle install
|
||||||
|
# rails g rolify Role User
|
||||||
|
# rails db:migrate
|
||||||
|
|
||||||
# mariams box:
|
# mariams box:
|
||||||
# mariam@flippy:~/obdev$ make version
|
# mariam@flippy:~/obdev$ make version
|
||||||
# Rails 7.1.2
|
# Rails 7.1.2
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Form < ApplicationRecord
|
||||||
# Assuming each form can have many onboarding items associated with different owners.
|
# Assuming each form can have many onboarding items associated with different owners.
|
||||||
has_many :onboarding_items
|
has_many :onboarding_items
|
||||||
has_many :forms_roles
|
has_many :forms_roles
|
||||||
has_many :roles, through: :forms_roles
|
has_many :form_roles, through: :forms_roles
|
||||||
accepts_nested_attributes_for :forms_roles, allow_destroy: true
|
accepts_nested_attributes_for :forms_roles, allow_destroy: true
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Role < ApplicationRecord
|
class FormRole < ApplicationRecord
|
||||||
has_many :forms_roles
|
has_many :forms_roles
|
||||||
has_many :forms, through: :forms_roles
|
has_many :forms, through: :forms_roles
|
||||||
end
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
class FormsRole < ApplicationRecord
|
class FormsRole < ApplicationRecord
|
||||||
belongs_to :form
|
belongs_to :form
|
||||||
belongs_to :role
|
belongs_to :form_role
|
||||||
attribute :note, :string
|
attribute :note, :string
|
||||||
attribute :date_completed, :date
|
attribute :date_completed, :date
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,3 @@
|
||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
# Include default devise modules. Others available are:
|
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable
|
||||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
|
||||||
devise :database_authenticatable, :registerable,
|
|
||||||
:recoverable, :rememberable, :validatable
|
|
||||||
|
|
||||||
|
|
||||||
def admin?
|
|
||||||
self.admin
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h2 class="mb-3 text-center">Log in</h2>
|
<h2 class="mb-3 text-center">Log in</h2>
|
||||||
|
|
||||||
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: 'needs-validation', novalidate: true }) do |f| %>
|
<%= form_with(model: resource, as: resource_name, url: user_session_path, local: true, html: { class: 'needs-validation', novalidate: true }) do |f| %>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<%= f.label :email, class: 'form-label' %>
|
<%= f.label :email, class: 'form-label' %>
|
||||||
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control', placeholder: 'Enter email' %>
|
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control', placeholder: 'Enter email' %>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||||
<%= link_to "Forgot your password?", new_password_path(resource_name), class: "btn btn-link" %>
|
<%= link_to "Forgot your password?", new_user_password_path(resource_name), class: "btn btn-link" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<td><%= form.name %></td>
|
<td><%= form.name %></td>
|
||||||
<td><%= form.required ? 'Required' : 'Optional' %></td>
|
<td><%= form.required ? 'Required' : 'Optional' %></td>
|
||||||
<td><%= form.program %></td>
|
<td><%= form.program %></td>
|
||||||
<td><%= form.roles.map(&:name).join(", ") %></td>
|
<td><%= form.form_roles.map(&:name).join(", ") %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to edit_form_path(form), class: 'btn btn-info btn-sm' do %>
|
<%= link_to edit_form_path(form), class: 'btn btn-info btn-sm' do %>
|
||||||
<i class="bi bi-pencil-fill" style="color: white;"></i>
|
<i class="bi bi-pencil-fill" style="color: white;"></i>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenameRoleToFormRole < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
rename_table :roles, :form_roles
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class FixFormRoleIdInFormsRoles < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
# Rename role_id to form_role_id if the column exists
|
||||||
|
# This is necessary to match the updated association in your models
|
||||||
|
if column_exists?(:forms_roles, :role_id)
|
||||||
|
rename_column :forms_roles, :role_id, :form_role_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2024_02_17_063857) do
|
ActiveRecord::Schema[7.1].define(version: 2024_04_02_214014) do
|
||||||
create_table "bank_accounts", force: :cascade do |t|
|
create_table "bank_accounts", force: :cascade do |t|
|
||||||
t.string "institution_name"
|
t.string "institution_name"
|
||||||
t.string "account_type"
|
t.string "account_type"
|
||||||
|
@ -72,6 +72,12 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_17_063857) do
|
||||||
t.index ["worker_id"], name: "index_employments_on_worker_id"
|
t.index ["worker_id"], name: "index_employments_on_worker_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "form_roles", force: :cascade do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "forms", force: :cascade do |t|
|
create_table "forms", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
@ -83,13 +89,13 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_17_063857) do
|
||||||
|
|
||||||
create_table "forms_roles", force: :cascade do |t|
|
create_table "forms_roles", force: :cascade do |t|
|
||||||
t.integer "form_id", null: false
|
t.integer "form_id", null: false
|
||||||
t.integer "role_id", null: false
|
t.integer "form_role_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "note"
|
t.string "note"
|
||||||
t.date "date_completed"
|
t.date "date_completed"
|
||||||
t.index ["form_id"], name: "index_forms_roles_on_form_id"
|
t.index ["form_id"], name: "index_forms_roles_on_form_id"
|
||||||
t.index ["role_id"], name: "index_forms_roles_on_role_id"
|
t.index ["form_role_id"], name: "index_forms_roles_on_form_role_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "onboarding_items", force: :cascade do |t|
|
create_table "onboarding_items", force: :cascade do |t|
|
||||||
|
@ -143,12 +149,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_17_063857) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "roles", force: :cascade do |t|
|
|
||||||
t.string "name"
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "service_contracts", force: :cascade do |t|
|
create_table "service_contracts", force: :cascade do |t|
|
||||||
t.integer "participant_id", null: false
|
t.integer "participant_id", null: false
|
||||||
t.integer "vendor_id", null: false
|
t.integer "vendor_id", null: false
|
||||||
|
@ -214,8 +214,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_17_063857) do
|
||||||
add_foreign_key "employer_records", "participants"
|
add_foreign_key "employer_records", "participants"
|
||||||
add_foreign_key "employments", "participants"
|
add_foreign_key "employments", "participants"
|
||||||
add_foreign_key "employments", "workers"
|
add_foreign_key "employments", "workers"
|
||||||
|
add_foreign_key "forms_roles", "form_roles"
|
||||||
add_foreign_key "forms_roles", "forms"
|
add_foreign_key "forms_roles", "forms"
|
||||||
add_foreign_key "forms_roles", "roles"
|
|
||||||
add_foreign_key "participants", "employers"
|
add_foreign_key "participants", "employers"
|
||||||
add_foreign_key "participants", "workers"
|
add_foreign_key "participants", "workers"
|
||||||
add_foreign_key "service_contracts", "participants"
|
add_foreign_key "service_contracts", "participants"
|
||||||
|
|
Loading…
Reference in New Issue