-
-
Save staycreativedesign/568f07938591d2a8a844d3857c4aac4a to your computer and use it in GitHub Desktop.
Trying to get Entry to list details
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
%h1 | |
hello | |
- detail_subs.each do |sub| | |
.form-group | |
= sub.title | |
= select_tag(:detail_ids, options_for_select(sub.details.pluck('title', 'id', entry.detail_ids), selected: @entry.detail_ids), multiple: true, class: 'chosen-select form-control') | |
:javascript | |
$(function() { | |
$(".chosen-select").chosen(); | |
}) |
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
# == Schema Information | |
# | |
# Table name: details | |
# | |
# id :bigint not null, primary key | |
# title :string | |
# type :string | |
# category :string | |
# detail_sub_id :bigint | |
# entry_id :integer | |
# | |
class Detail < ApplicationRecord | |
belongs_to :detail_sub | |
has_many :entry_details | |
has_many :entries, through: :entry_details | |
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
def entry_params | |
params.require(:entry).permit(:title, :subtitle, :of_type, :intro, :content, | |
:promo, :author, :address, :city, :state, :zipcode, | |
:lat, :long, :directions, :website, :email, :synonyms, | |
:facebook, :instagram, :twitter, :pinterest, :details, | |
:meta_description, :meta_title, :meta_keywords, | |
:facility, :group, :internet, :room, :room_amenities, | |
:discounts, :slug, :type_id, :lake_assn, :detail_category_id, | |
:featured_image, :is_featured, images: [], | |
phone_numbers_attributes: [:id, :label, :number, :_destroy], | |
videos_attributes: [:id, :url, :_destroy], | |
hours_attributes: [:id, :title, :label_1, :label_2, :_destroy], | |
prices_attributes: [:id, :label, :price, :_destroy], | |
related_entry_ids: [],topic_ids: [], | |
documents_attributes: [:id, :position, :title], | |
detail_ids: [] | |
) | |
end | |
# I have detail_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 Entry < ApplicationRecord | |
has_many :entry_details | |
has_many :details, through: :entry_details | |
belongs_to :detail_category, optional: true | |
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
# == Schema Information | |
# | |
# Table name: entry_details | |
# | |
# id :bigint not null, primary key | |
# entry_id :bigint | |
# detail_id :bigint | |
# | |
class EntryDetail < ApplicationRecord | |
belongs_to :entry | |
belongs_to :detail | |
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
irb(main):003:0> EntryDetail.all | |
EntryDetail Load (0.4ms) SELECT "entry_details".* FROM "entry_details" LIMIT $1 [["LIMIT", 11]] | |
=> #<ActiveRecord::Relation []> | |
irb(main):004:0> |
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
DetailCategory has_many Entries | |
DetailCategory has_may DetailSubs | |
DetailSubs has_many Details | |
DetailofAmenities belongs_to :entry | |
DetailofAmenities belongs_to :detail_sub | |
1 DetailofAmenities can belong to many entries | |
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/entries/corksville" for ::1 at 2020-03-18 07:13:05 -0500 | |
Processing by Admin::EntriesController#update as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"g7tNb1PweBx8WIydQFWIbcgOfsPHBnY3DQdcX7D/qy6tdRXryG5WLWuMAz/xPACAfNTz2VIXOMJgDrp5/MuXvw==", "entry"=>{"related_entry_ids"=>[""], "promo"=>"0", "is_featured"=>"0", | |
"title"=>"Corksville", "type_id"=>"1", "topic_ids"=>["4", "5"], "subtitle"=>"fluff", "synonyms"=>"fart", "intro"=>"<p>fluff</p>", "content"=>"<p>fluff</p>", "detail_category_id"=>"4", "address"=>"", "city"=>"", | |
"state"=>"", "zipcode"=>"", "email"=>"", "website"=>"", "lake_assn"=>"", "lat"=>"36.743958", "long"=>"-95.931505", "phone_numbers_attributes"=>{"0"=>{"label"=>"", "number"=>"", "_destroy"=>"false"}}, "facility"=> | |
"", "group"=>"", "internet"=>"", "room"=>"", "room_amenities"=>"", "discounts"=>"", "hours_attributes"=>{"0"=>{"title"=>"", "label_1"=>"", "label_2"=>"", "_destroy"=>"false"}}, "prices_attributes"=>{"0"=>{"label" | |
=>"", "price"=>"", "_destroy"=>"false"}}, "meta_title"=>"", "meta_description"=>"", "meta_keywords"=>"", "facebook"=>"", "instagram"=>"", "pinterest"=>"", "twitter"=>""}, "detail_ids"=>["18", "19"], "commit"=>"Up | |
date Entry", "id"=>"corksville"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment