Skip to content

Instantly share code, notes, and snippets.

@scottshea
scottshea / meeting_shared_delegates.rb
Created May 11, 2012 22:17
meetings_shared_delegates
shared_examples_for "Meeting Delegates" do
describe "#organization_name"do
it "should return the organization_name from the delegate" do
subject.organization_name.should == subject.organization.name
end
end
describe "#address" do
it "should return the organization address from the delegate" do
subject.address.should == subject.organization.address
@scottshea
scottshea / dcp_meeting_spec.rb
Created May 11, 2012 22:21
dcp_meeting_spec
require 'spec_helper'
describe DcpMeeting do
it { should have_one :checkpoint }
it { should belong_to :coach }
it { should belong_to :organization }
it_should_behave_like "Meeting Delegates"
it "should be made with blueprints" do
require 'spec_helper'
describe DcpMeeting do
it { should have_one :checkpoint }
it { should belong_to :coach }
it { should belong_to :organization }
it_should_behave_like "Meeting Delegates"
it "should be made with blueprints" do
@scottshea
scottshea / gist:2955448
Created June 19, 2012 17:33
Stack Trace for Rake Task failue
WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called.
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Unknown alias: test
/home/scott/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:239:in `block in visit_Psych_Nodes_Alias'
/home/scott/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:239:in `fetch'
/home/scott/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:239:in `visit_Psych_Nodes_Alias'
@scottshea
scottshea / gist:2955482
Created June 19, 2012 17:39
Database.yml
# SQLite version 3.x
# gem install sqlite3
development:
adapter: mysql
encoding: utf8
reconnect: false
database: activate_development
pool: 5
user:
password:
@scottshea
scottshea / gist:2968909
Created June 21, 2012 22:13
Stack Trace
Using the default profile...
undefined method `klass' for nil:NilClass (NoMethodError)
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activesupport-3.0.13/lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activerecord-3.0.13/lib/active_record/reflection.rb:346:in `block in source_reflection'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activerecord-3.0.13/lib/active_record/reflection.rb:346:in `collect'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activerecord-3.0.13/lib/active_record/reflection.rb:346:in `source_reflection'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activerecord-3.0.13/lib/active_record/reflection.rb:407:in `derive_class_name'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activerecord-3.0.13/lib/active_record/reflection.rb:121:in `class_name'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/activerecord-3.0.13/lib/active_record/reflection.rb:162:in `klass'
/home/scott/.rvm/gems/ruby-1.9.3-p194@rails3/gems/active_
@scottshea
scottshea / gist:2968923
Created June 21, 2012 22:15
SubScreensController
class SubScreensController < ApplicationController
load_and_authorize_resource
active_scaffold :sub_screen do |conf|
end
end
def create_asset
@asset = Asset.new(:name => params[:name],
:description => params[:description],
:serial_number => params[:serial_number],
:asset_manufacturer_id => params[:asset_manufacturer_id],
:asset_model_id => params[:asset_model_id],
:image_filename => params[:image_filename])
respond_to do |format|
format.js
@scottshea
scottshea / activate_users_controller.rb
Created July 10, 2012 18:06
Activate User Controller
class ActivateUsersController < ApplicationController
load_and_authorize_resource :class => false
before_filter :populate_roles, :only => [:new_user, :update_user]
# GET /users
# GET /users.xml
def index
@users = User.all
respond_to do |format|
@scottshea
scottshea / gist:3739990
Created September 17, 2012 21:47
Partial with select changing
<%= form_for :asset, :url => {:controller => "import", :action => "asset_check", :format => :js }, :options => { :remote => true }, :html => {:method => :post, :class => "well form-horizontal"} do |f| %>
<%= f.submit "Check File", :class => "btn" %> </br>
<%= f.label 'Configuration', "Field Mapping:", :class => "control-label" %>
<div class="controls">
<%= f.select('csv_configurations', options_from_collection_for_select(@csv_configurations, "id", "name"), {:include_blank => true}, {:id => "csv_configuration", :onchange => "load_mapping(this.value)"}) %>
</div>
<% @csv.headers.each do |head| %>
<%= f.label head, head.humanize, :class => "control-label", :id => "#{head}_id" %>
<div class="controls">