Skip to content

Instantly share code, notes, and snippets.

View ddellacosta's full-sized avatar

Dave Della Costa ddellacosta

View GitHub Profile
def use
@configuration ||= {}
yield @configuration
nil
end
@ddellacosta
ddellacosta / gist:710670
Created November 22, 2010 21:01
acts_as_taggable_on saving from parent relation
irb(main):094:0> @dfd.is_a?(User)
=> true
irb(main):095:0> @dfd.is_tagger?
=> true
irb(main):096:0> @alink = { :name => 'google', :link => 'http://google.com', :description => '', :tag_list => 'hello' }
=> {:name=>"google", :link=>"http://google.com", :description=>"", :tag_list=>"hello"}
irb(main):097:0> new_link = @dfd.links.new(@alink)
=> #<Link id: nil, name: "google", description: "", link: "http://google.com", created_at: nil, updated_at: nil, user_id: 1>
irb(main):098:0> new_link.tag_list
=> []
@ddellacosta
ddellacosta / gist:712223
Created November 23, 2010 18:11
Rails 3.0.1 + acts_as_taggable_on 2.0.6
links-tag-test $ bundle exec rails console
Loading development environment (Rails 3.0.1)
irb(main):001:0> @link1 = Link.create(:name => 'google', :link => 'http://google.com', :description => 'google', :tag_list => 'tag1, tag2, tag3')
=> #<Link id: 12, name: "google", description: "google", link: "http://google.com", created_at: "2010-11-23 18:09:37", updated_at: "2010-11-23 18:09:37", user_id: nil>
irb(main):002:0> @link1.is_taggable?
=> true
irb(main):003:0> @link1.tag_list
=> []
irb(main):004:0> @link2 = Link.new(:name => 'yahoo', :link => 'http://yahoo.com', :description => 'yahoo')
=> #<Link id: nil, name: "yahoo", description: "yahoo", link: "http://yahoo.com", created_at: nil, updated_at: nil, user_id: nil>
@ddellacosta
ddellacosta / gist:943731
Created April 27, 2011 04:46
Why the heck isn't acts_as_taggable_on working in this model?
#### Rails console ####
irb(main):091:0> @doc.tag_list
=> []
irb(main):092:0> @doc.tag_list = "one, two, three"
=> "one, two, three"
irb(main):093:0> @doc.save!
=> true
irb(main):094:0> @doc.tag_list
=> []
irb(main):095:0> ActsAsTaggableOn::Tag.named("one")
# UTF-8 value on page:
"Adélaïde de Hongrie"
# GET string:
Started GET "/registers/results?filter[title][]=Ad%E9la%EFde%20de%20Hongrie&search=&limit=4" for 127.0.0.1 at 2011-05-16 14:17:33 +0700
# What Rails gets/Rack produces (in Controller):
/Library/WebServer/Deployment/miximize:$ be bin/rails s
DEPRECATION WARNING: ref is deprecated and will be removed from Rails 3.2. (called from require at /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68)
DEPRECATION WARNING: new is deprecated and will be removed from Rails 3.2. (called from require at /opt/local/lib/ruby1.9/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68)
=> Booting WEBrick
=> Rails 3.1.0.rc5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Library/WebServer/Deployment/miximize/vendor/ruby/1.9.1/gems/devise-1.1.7/lib/devise/mapping.rb:40:in `find_scope!': Could not find a valid mapping for #<User:0x000001033354b0> (RuntimeError)
from /Library/WebServer/Deployment/miximize/vendor/ruby/1.9.1/gems/devise-1.1.7/app/mailers/devise/mailer.rb:21:in `setup_mail'
@ddellacosta
ddellacosta / gist:1139025
Created August 11, 2011 06:29
why aren't my models getting loaded in my app?
# in plugin_dir/lib/plugin_name.rb
...
%w{ models controllers }.each do |dir|
path = File.join(File.dirname(__FILE__), 'app', dir)
$LOAD_PATH << path
# it would be nice if someone updated the documentation.
ActiveSupport::Dependencies.autoload_paths << path
ActiveSupport::Dependencies.autoload_once_paths.delete(path)
end
@ddellacosta
ddellacosta / gist:1158825
Created August 20, 2011 07:56
Initializer not getting called?
module Thinger
extend ActiveSupport::Concern
module ClassMethods
def acts_as_something
class_eval do
has_many :assignments
has_many :things, :through => :assignments
attr_accessible :things
@ddellacosta
ddellacosta / gist:3727361
Created September 15, 2012 11:05
not really feeling like idiomatic Clojure code here
(map
#(clojure.string/replace (clojure.string/replace (.getPath %1) #"resources/assets/" "") #"/./" "/")
files))
@ddellacosta
ddellacosta / gist:5590699
Created May 16, 2013 10:02
can't connect to browser
nREPL server started on port 60277
REPL-y 0.1.10
Clojure 1.5.1
Exit: Control+D or (exit) or (quit)
Commands: (user/help)
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
(user/sourcery function-name-here)
Javadoc: (javadoc java-object-or-class-here)