Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
staycreativedesign / codes1.txt
Last active September 17, 2018 15:58
I am trying to load this file which has an array of strings but when I load it it doesn't separate the the values... what am I doing wrong?
["foo","bar","biz"]
- Category.all.each do |category|
%li
= link_to(category.title, category_path(category))
- unless category.subcategories.blank?
%ul
- category.subcategories.each do |subcat|
%li
= link_to(subcat.title, category_subcategory_posts_path(category, subcat))
if category = category.subcategories.where(title: subcategory).present?
subcategory category.subcategories.where(title: subcategory)
else
subcategory = Subcategory.create(category_id: category_id, title: subcategory)
end
Conversion Class 1102: The laws of Prayer:
Introduction Part 2
I. Communal Worship
A. The Merit of Communal Worship
1. One of the distinctive features of Jewish prayer from its earliest
beginnings was this emphasis on communal or congregational
worship. One may fulfill the mitzvah of prayer by praying
privately (and there will be a distinction between women and
@staycreativedesign
staycreativedesign / _submenus_menu.haml
Created November 4, 2018 21:55
Goal: Whenever a user changes the category I want the submenu to change to the correct submenu options. Problem: Everytime I change a category in the network tab in chrome it shows below...
= select_tag "post[submenu_id]", options_from_collection_for_select(@category.submenus, "id", "title")
@staycreativedesign
staycreativedesign / foo.js
Created November 5, 2018 17:45
how can i better write this, if post_category id change then it goes down to change submenu and subcategory, if submenu is changed it changes the subcategory
$('#post_category_id').change(function(e){
var cat = this.value
$.getScript('/admin/categories/' + this.value + '/submenus', function(e){
var submenu = $('#post_submenu_id').val();
if (submenu == null) {
} else {
$.getScript('/admin/categories/' + cat + '/submenus/' + submenu + '/subcategories')
}
})
})
function reloadSubCategories (category, submenu) {
if (category && submenu) {
$.getScript('/admin/categories/'+ category +'/submenus/'+ submenu +'/subcategories');
} else {
$('#post_subcategory_id').replaceWith("<select name='post[subcategory_id]' id='post_subcategory_id'></select>" );
}
}
$('#post_category_id').parent().on('change', '#post_category_id', function(e){
var cat = this.value;
function reloadSubCategories (category, submenu) {
if (category && submenu) {
$('#new_subcategory').attr('action', '/admin/categories/' + category + '/submenus/'+ submenu + '/subcategories')
$.getScript('/admin/categories/'+ category +'/submenus/'+ submenu +'/subcategories');
} else {
$('#post_subcategory_id').empty();
}
}
$('#new_post').parent().on('change', '#new_post', function(e){
def create
@amount = params[:amount]
@amount = @amount.gsub('$', '').gsub(',', '')
begin
@amount = Float(@amount).round(2)
rescue
flash[:error] = 'Charge not completed. Please enter a valid amount in USD ($).'
redirect_to new_charge_path
class ChargesController < ApplicationController
def new
end
def create
@amount = params[:amount]
@amount = @amount.gsub('$', '').gsub(',', '')
begin