Skip to content

Instantly share code, notes, and snippets.

@jgautsch
jgautsch / gist:5144281
Created March 12, 2013 16:18
Submitting an extra null element
Couldn't find all Roles with IDs (5, ) (found 1 results, but was looking for 2)
<div id="role-options-<%= user.id %>" class="modal" style="display: none;">
<%= simple_form_for user, :url => user_path(user), :html => {:method => :put, :class => 'form-horizontal' } do |f| %>
<div class="modal-header">
<a class="close" data-dismiss="modal">&#215;</a>
<h3>Change Role Test</h3>
</div>
<div class="modal-body">
<%= f.input :role_ids, :collection => Role.all, :as => :check_boxes, :label_method => lambda {|t| t.name.titleize}, :label => false, :item_wrapper_class => 'vertical', checked: user.role_ids %>
@jgautsch
jgautsch / gist:5156100
Created March 13, 2013 20:58
Models and associations
class User < ActiveRecord::Base
.
. # ... = stuff irrelevant to the problem
.
has_one :schedule
.
.
.
end
@jgautsch
jgautsch / gist:5316097
Created April 5, 2013 02:17
Query fiddling
1.9.3-p374 :015 > @books = @books.where(['substr(title,1,1) in ?', ('A'..'T').to_a])
Book Load (41.2ms) SELECT "books".* FROM "books" WHERE (substr(title,1,1) in 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T')
SQLite3::SQLException: near ",": syntax error: SELECT "books".* FROM "books" WHERE (substr(title,1,1) in 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T')
ActiveRecord::StatementInvalid: SQLite3::SQLException: near ",": syntax error: SELECT "books".* FROM "books" WHERE (substr(title,1,1) in 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T')
@jgautsch
jgautsch / gist:5373034
Created April 12, 2013 15:54
LOGAN Center 2/3 Code example
############################################
# Application Controller - CanCan
############################################
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_path, :alert => exception.message
end
<?xml version="1.0" encoding="UTF-8"?>
<objects type="array">
<object>
<service-type-code>1</service-type-code>
<description>Medical Care</description>
<children type="array">
<child>2</child>
<child>42</child>
<child>45</child>
<child>69</child>
@jgautsch
jgautsch / weird.rb
Created July 2, 2013 01:52
JS being in my html from the db
# THis is the controller action
def first_step
@payers = sorted_payers
end
private
def sorted_payers
@label1 = Payer.new(name: "<script>$( document ).ready(function() {alert( 'ready!' );});</script>")
end
@jgautsch
jgautsch / gist:6225904
Created August 13, 2013 21:32
Capistrano asset compilation problem
* 2013-08-13 16:25:28 executing `deploy:assets:precompile'
triggering before callbacks for `deploy:assets:precompile'
* 2013-08-13 16:25:28 executing `deploy:assets:update_asset_mtimes'
* executing "[ -e /mnt/workmein-production/shared/assets/manifest* ] && cat /mnt/workmein-production/shared/assets/manifest* || echo"
servers: ["production.foo.com"]
[production.foo.com] executing command
command finished in 147ms
* 2013-08-13 16:25:28 executing `deploy:assets:symlink'
* executing "rm -rf /mnt/workmein-production/releases/20130813212515/public/assets && mkdir -p /mnt/workmein-production/releases/20130813212515/public && mkdir -p /mnt/workmein-production/shared/assets && ln -s /mnt/workmein-production/shared/assets /mnt/workmein-production/releases/20130813212515/public/assets"
servers: ["production.foo.com"]
@jgautsch
jgautsch / _.md
Created August 20, 2013 18:07
[dot append: 03] electron
@jgautsch
jgautsch / _.md
Created August 20, 2013 19:09
[dot append: 06] simple transition
@jgautsch
jgautsch / _.md
Created August 20, 2013 19:35
[dot enter: 07] stacks