Skip to content

Instantly share code, notes, and snippets.

View karledurante's full-sized avatar

Karle Durante karledurante

  • CustomInk.com
  • Ashburn, VA
View GitHub Profile
@karledurante
karledurante / tabless_model.rb
Created July 14, 2011 12:26
Example of a tabless model that lets you harness the power of activerecord, without the baggage of a DB table
## A "Tabless" Model that you can extend to get the features and benefits
## of an ActiveRecord model, without having to persist anything to the database
class TablessModel < ActiveRecord::Base
self.abstract_class = true
def self.columns() @columns ||= []; end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
@karledurante
karledurante / gist:1253963
Created September 30, 2011 14:48
rack-esi config
# environment.rb
Rails::Initializer.run do |config|
config.middleware.use(Rack::ESI, opts = {})
... other configs....
end
@karledurante
karledurante / gist:1266270
Created October 6, 2011 01:38
views...no layout
# view
<%- content_for :head do -%>
hi?
<esi:include src="/pricing/delivery_quote" />
<%- end -%>
# the layout is a bit harder since it's a series of partials that will render other partials, etc. I will try to take some time to boil it down to something simple that i can post.
# Layout
<html>
<head>
</head>
<body>
<h1>header</h1>
<p>hi</p>
<h2>content</h2>
<%= yield %>
@karledurante
karledurante / gist:1406026
Created November 29, 2011 19:15
Rails 3 - Oracle Enhanced Adapter Issue - Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem "ruby-oci8", "2.0.4"
gem "activerecord-oracle_enhanced-adapter", "1.4.0"
gem "mysql", "2.8.1"
@karledurante
karledurante / gist:1406039
Created November 29, 2011 19:17
Rails 3 - Oracle Enhanced Adapter Issue - database.yml
development:
adapter: oracle_enhanced
username: development
password: password
database: oracle.local/YOUR_SID
mysql_db:
adapter: mysql
encoding: utf8
host: localhost
@karledurante
karledurante / gist:1406043
Created November 29, 2011 19:18
Rails 3 - Oracle Enhanced Adapter Issue - MySQL Model
class SomeModel < ActiveRecord::Base
establish_connection ActiveRecord::Base.configurations['mysql_db']
end
@karledurante
karledurante / gist:1406055
Created November 29, 2011 19:21
Rails 3 - Oracle Enhanced Adapter Issue - Error
>> SomeModel.create(:name => 'foo')
NoMethodError: undefined method `virtual?' for #<ActiveRecord::ConnectionAdapters::MysqlColumn:0x1017eaea8>
from (irb):6:in `to_proc'
from /Users/kdurante/.rvm/gems/ree-1.8.7-2010.02@oracle_adapter/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:91:in `select'
from /Users/kdurante/.rvm/gems/ree-1.8.7-2010.02@oracle_adapter/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:91:in `arel_attributes_values'
from /Users/kdurante/.rvm/gems/ree-1.8.7-2010.02@oracle_adapter/gems/activerecord-3.0.7/lib/active_record/persistence.rb:253:in `update'
from /Users/kdurante/.rvm/gems/ree-1.8.7-2010.02@oracle_adapter/gems/activerecord-3.0.7/lib/active_record/locking/optimistic.rb:77:in `update'
from /Users/kdurante/.rvm/gems/ree-1.8.7-2010.02@oracle_adapter/gems/activerecord-3.0.7/lib/active_record/attribute_methods/dirty.rb:68:in `update'
from /Users/kdur
@karledurante
karledurante / gist:1555451
Created January 3, 2012 15:51
Rails 3 Functional Test: assert_select finds nothing on XHR requests
setup do
xhr :post, :summarize
end
should "find a tag" do
# FAILS in Rails3, SUCCEEDS in Rails2
assert_select :span, :text => "some content"
# SUCCEEDS in Rails3 & Rails2
assert_match /\<span\>some content<\/span\>/, @response.body
@karledurante
karledurante / gist:2421364
Created April 19, 2012 14:38
Alternative to alias_method_chain
class Something
module Base
def my_method
# (A) original functionality
end
end
module PreExtension
def my_method
# (B) before the original