Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
staycreativedesign / foo.js
Last active November 13, 2018 22:47
Uncaught SyntaxError: Unexpected token - Line 5
%script{:src => "https://checkout.stripe.com/checkout.js"}
:javascript
var handler = StripeCheckout.configure({
key: '#{Rails.configuration.stripe[:publishable_key]}',
locale: 'auto',
name: 'foobar',
description: 'Donation',
token: function(token) {
$('input#stripeToken').val(token.id);
$('form').submit();
class ChargesController < ApplicationController
def new
end
def create
@amount = params[:amount]
@amount = @amount.gsub('$', '').gsub(',', '')
begin
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
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){
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;
@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')
}
})
})
@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")
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
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
- 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))