Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/project_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ProjectUser < ApplicationRecord

# Validations
validates_presence_of :project_id
validates_presence_of :title

# Enum
enum :position, { default: 0, liaison: 1, leader: 2, assistant: 3 }
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ class User < ApplicationRecord
# Nested attributes
accepts_nested_attributes_for :user_forms
accepts_nested_attributes_for :project_users, allow_destroy: true,
reject_if: proc { |attrs| attrs["project_id"].blank? || attrs["title"].blank? }
reject_if: proc { |attrs| attrs["project_id"].blank? && attrs["title"].blank? }

# Validations
validates :email, presence: true, uniqueness: { case_sensitive: false }
validates_associated :project_users

# Search Cop
include SearchCop
Expand Down
4 changes: 3 additions & 1 deletion app/views/facilitators/_project_user_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
selected: f.object.project_id,
input_html: {
class: "block w-full rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500"
} %>
},
required: true,
error: "Organization can't be blank" %>
</div>

<div>
Expand Down
2 changes: 1 addition & 1 deletion spec/views/users/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
let!(:workshop) { create(:workshop, title: "Mindful Art", user: user, windows_type: windows_type) }

let!(:project) { create(:project, name: "Healing Arts") }
let!(:project_user) { create(:project_user, project: project, user: user, position: :leader) }
let!(:project_user) { create(:project_user, project: project, title: "Title", user: user, position: :leader) }

before do
assign(:user, user)
Expand Down