Created
March 31, 2020 15:26
-
-
Save staycreativedesign/7aef2f74070ce87738815618ad507f6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for([:admin, @staff]) do |f| | |
.row.mt-5 | |
.col-sm-12 | |
.form-group | |
= f.label :specializations | |
.form-group | |
= f.select(:specialization_ids, options_from_collection_for_select(Specialization.all, 'id', 'title', f.object.specialization_ids), {}, multiple: true, class: 'chosen-select form-control') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Faculty < ApplicationRecord | |
has_many :faculty_specializations | |
has_many :specializations, through: :faculty_specializations | |
has_and_belongs_to_many :pages | |
extend FriendlyId | |
friendly_id :title, use: :slugged | |
has_one_attached :profile | |
def should_generate_new_friendly_id? | |
title_changed? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FacultySpecialization < ApplicationRecord | |
belongs_to :faculty | |
belongs_to :specialization | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started PATCH "/admin/faculties/holly-farmer-2" for ::1 at 2020-03-31 10:25:23 -0500 | |
Processing by Admin::FacultiesController#update as HTML | |
Parameters: {"authenticity_token"=>"lqKy+FsPrwFPYJzf6d9lNY/lxzNB7f8gnrMG/OGHUg6/+pDQ8Jv2SFI524VZbLUluFKnnrErrsbzbl9AtxegeA==", "faculty"=>{"title"=>"Ali Carpenter", "staff_title"=>"Business & Information Techno | |
logy Education Teaching Assistant", "email"=>"ali@pioneertech.edu", "phone"=>"580-418-4365", "website"=>"", "specialization_ids"=>[""]}, "commit"=>"Update Faculty", "id"=>"holly-farmer-2"} | |
Unpermitted parameter: :specialization_ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Specialization < ApplicationRecord | |
has_many :faculty_specializations | |
has_many :faculties, through: :faculty_specializations | |
extend FriendlyId | |
friendly_id :title, use: :slugged | |
validates_uniqueness_of :title | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment