Skip to content

Instantly share code, notes, and snippets.

@mhinton
mhinton / gist:479837
Created July 17, 2010 20:33
ActiveRecord Error
def update_order
@idlist = params[:id]
@todays_list = ActionList.today.first
@todays_list.reorder_action_items(@idlist)
end
class ActionList < ActiveRecord::Base
has_many :action_items
@mhinton
mhinton / gist:742017
Created December 15, 2010 14:44
sphinx config for publication
source publication_core_0
{
type = pgsql
sql_query_pre = SET TIME ZONE 'UTC'
sql_query = SELECT "publications"."id" * 5 + 3 AS "id" , CAST(COALESCE("editions"."title_prefix", '') as varchar) || ' ' || CAST(COALESCE("editions"."title", '') as varchar) || ' ' || CAST(COALESCE("editions"."subtitle", '') as varchar) AS "title", array_to_string(array_accum(COALESCE(CAST(COALESCE("profiles"."given_names", '') as varchar) || ' ' || CAST(COALESCE("profiles"."surname", '') as varchar), '0')), ' ') AS "author", CAST(COALESCE("editions"."short_description", '') as varchar) || ' ' || CAST(COALESCE("editions"."long_description", '') as varchar) AS "description", "editions"."abstract" AS "abstract", "publications"."id" AS "sphinx_internal_id", 2640206651 AS "class_crc", 0 AS "sphinx_deleted", COALESCE("editions"."title_prefix", '') || ' ' || COALESCE("editions"."title", '') || ' ' || COALESCE("editions"."subtitle", '') AS "title_sort", array_to_string(array_accum(COALESCE(COALESCE("profiles"."given_names", '') || ' '
@mhinton
mhinton / rails 3 app template
Created February 3, 2011 19:39
this is a basic rails 3 app template
rvmrc = <<-RVMRC
rvm gemset use #{app_name}
RVMRC
create_file ".rvmrc", rvmrc
gem "devise"
gem "formtastic", '~> 1.2.3'
gem "client_side_validations"
gem "factory_girl_rails", ">= 1.0.0", :group => :test
@mhinton
mhinton / gist:935273
Created April 21, 2011 19:15
Rails Configuration Information
<%
config = Rails::Configuration.new
host = config.database_configuration[RAILS_ENV]["host"]
database = config.database_configuration[RAILS_ENV]["database"]
username = config.database_configuration[RAILS_ENV]["username"]
password = config.database_configuration[RAILS_ENV]["password"]
-%>
<div>
<%= host %><br/>
<%= database %>
@mhinton
mhinton / gist:948345
Last active September 25, 2015 16:08
fields_for issue
# publications/:id/edit
def edit
@publication = CgPublisher::Publication.find(params[:id], :include => [{:version => { :work => :authorships }}, {:imprint => :subscriptions}])
end
# edit.html.erb
<% form_for @publication, :html => {:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
@mhinton
mhinton / gist:3490500
Created August 27, 2012 17:15
Full Stack Trace
/Users/matthew/Sites/uauthor/cg_role_client/lib/cg_role_client/aggregate_role.rb:40:in `role_for'
/Users/matthew/Sites/uauthor/cg_role_client/lib/cg_role_client/aggregate_role.rb:39:in `each'
/Users/matthew/Sites/uauthor/cg_role_client/lib/cg_role_client/aggregate_role.rb:39:in `role_for'
/Users/matthew/Sites/uauthor/cg_role_client/lib/cg_role_client/aggregate_role.rb:50:in `is_a?'
active_presenter (1.4.0) lib/active_presenter/base.rb:112:in `initialize'
active_presenter (1.4.0) lib/active_presenter/base.rb:110:in `each'
active_presenter (1.4.0) lib/active_presenter/base.rb:110:in `initialize'
app/controllers/cg_publisher/publishers_controller.rb:69:in `new'
app/controllers/cg_publisher/publishers_controller.rb:69:in `show'
activerecord (3.0.14) lib/active_record/relation.rb:13:in `each'
@mhinton
mhinton / gist:5826191
Last active December 18, 2015 18:29
Torquebox start error
Thu Jun 20 15:10:25 CDT 2013: Starting Torquebox Application Server: standalone.xml
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /usr/local/rvm/gems/jruby-1.7.4@global/gems/torquebox-server-2.3.0-java/jboss
JAVA: java
JAVA_OPTS: -server -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=
@mhinton
mhinton / gist:1365c9c7d2355e83ed85
Last active August 29, 2015 14:01
Meteor: Trying to dynamically render a template
Template.gem_view.context = function() {
return {
contentTemplate: "gems"
};
};
Template.page.render_content = function() {
var context = this;
var html = Template.no_template_found;
if (context && context.contentTemplate) {
@mhinton
mhinton / pubsub_issue.js
Last active August 29, 2015 14:05
Meteor Publish/Subscribe Issue
/* file: server/data.js */
Meteor.publish("helptexts",function() {
return HelpTexts.find();
});
Meteor.publish("publishTest", function () {
return HelpTexts.find({_id: "help-demo"});
});
@mhinton
mhinton / redirect_user.js
Created August 8, 2014 16:36
Meteor user redirect on session expiration
// file: server/data.js
/* Expose extra fields to the client side */
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
{fields: {'tw': 1, 'tw_user': 1, 'roles': 1, 'name': 1, 'forceLogout': 1}});
});
// file: client/base.js
user_subscription = Meteor.subscribe("userData");