Skip to content

Commit

Permalink
Merge pull request #123 from turingschool/Bug/company_model
Browse files Browse the repository at this point in the history
Fix/Company Model
  • Loading branch information
sethverrill authored Feb 11, 2025
2 parents 47e4c9d + 0e77b94 commit 1148a54
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def index
def create
authorize Contact
if (company = Company.find_company(@current_user, params[:company_id])) || params[:company_id].blank?
contact = Contact.create_optional_company(contact_params, @current_user.id, params[:company_id])
contact = Contact.create_optional_company(contact_params, @current_user.id, company&.id)
if contact.persisted?
render json: ContactsSerializer.new(contact), status: :created
else
Expand Down
2 changes: 1 addition & 1 deletion app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Company < ApplicationRecord
validates :city, presence: true, allow_blank: false
validates :state, presence: true, allow_blank: false
validates :zip_code, presence: true, allow_blank: false
validates :notes, presence: true, allow_nil: true
validates :notes, presence: true, allow_blank: true

def self.find_company(user, company_id)
if company = user.companies.find_by(id: company_id)
Expand Down

0 comments on commit 1148a54

Please sign in to comment.