Skip to content

Instantly share code, notes, and snippets.

" Delete current file
" -------------------------
map <Leader>df :call delete(expand('%')) \| bdelete!<CR>"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
<title></title>
</head>
= 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')
%h1
hello
- detail_subs.each do |sub|
.form-group
= sub.title
= binding.pry
= select_tag(:details, options_for_select(sub.details.pluck('title', 'id'), entry.detail_ids), multiple: true, class: 'chosen-select form-control')
:javascript
$(function() {
@staycreativedesign
staycreativedesign / _detail_subs.haml
Created February 20, 2020 12:37
This is what Im trying to do whenever a DetailCategory is selected it updates the _details_subs partial
- @detail_subs.each do |sub|
.form-group
= sub.title
= f.select(:detail_category_ids, options_from_collection_for_select(sub.details, 'id', 'title'), {}, class: 'chosen-select-detail form-control')
pages_controller.rb
def new
@pages_json = Page.all.map do |page|
{"name": page.title, "url": page.meta_slug}
end
@final_pages = @pages_json.to_json
end
@staycreativedesign
staycreativedesign / application.js
Created February 5, 2020 01:55
Getting a reference error : (index):96 Uncaught ReferenceError: Rails is not defined the Rails.ajax isn't working?
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require('jquery')
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
class Page < ApplicationRecord
extend FriendlyId
friendly_id :meta_slug, use: :slugged
has_one_attached :banner
def related_pages
pages_this_relates_to + pages_related_to_this
end
has_and_belongs_to_many :pages_this_relates_to,
@staycreativedesign
staycreativedesign / gist:686147f4a907460ff240c5198d41e925
Last active February 3, 2020 16:04
Regex on removing everything shown below inside the brackets
[
show_post_snippets post_type="staff" post_ids="17192" taxonomy="specialization" terms="" number_of_columns="3" post_count="1" image_size="small" hide_thumbnail="false" title="" no_margin="false" enable_sorting="true"
]
[/show_post_snippets]
@staycreativedesign
staycreativedesign / faculty.rb
Last active January 31, 2020 19:23
Trying to only list the faculty who have a specific specialization ( search by slug ) so if slug == nursing it only pulls up the faculty that has that specialization
class Faculty < ApplicationRecord
has_many :faculty_specializations
has_many :specializations, through: :faculty_specializations
extend FriendlyId
friendly_id :meta_slug, use: :slugged
has_one_attached :profile
end