This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product | |
include DataMapper::Resource | |
include Paperclip::Resource | |
property :id, Serial | |
property :name, String, :nullable => false, :index => :unique | |
property :description, String | |
property :price, Float, :default=>0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merb : worker (port 4000) ~ Started request handling: Sun Oct 19 14:52:21 -0400 2008 | |
merb : worker (port 4000) ~ Routed to: {"format"=>nil, "action"=>"new", "controller"=>"admin/products"} | |
merb : worker (port 4000) ~ Params: {"format"=>nil, "action"=>"new", "controller"=>"admin/products"} | |
~ SELECT "id", "name" FROM "tags" ORDER BY "id" | |
merb : worker (port 4000) ~ undefined method `image_1' for #<Product:0x2ae9000> - (NoMethodError) | |
/opt/local/lib/ruby/gems/1.8/gems/merb-helpers-0.9.9/lib/merb-helpers/form/builder.rb:274:in `send' | |
/opt/local/lib/ruby/gems/1.8/gems/merb-helpers-0.9.9/lib/merb-helpers/form/builder.rb:274:in `control_value' | |
/opt/local/lib/ruby/gems/1.8/gems/merb-helpers-0.9.9/lib/merb-helpers/form/builder.rb:32:in `bound_file_field' | |
/opt/local/lib/ruby/gems/1.8/gems/merb-helpers-0.9.9/lib/merb-helpers/form/helpers.rb:348:in `file_field' | |
/Users/mwm4n/Projects/fw-windows-merb/app/views/admin/products/_fields.html.erb:49:in `__Users__mwm4n__Projects__fw__windows__merb__app__views__admin__p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# solr query builder | |
response = solr.search do |s| | |
s.query '' | |
s.phrase_query '' | |
s.filter :author, 'ernst' | |
s.phrase_filter :location, 'South' | |
s.fq '' # override / merge s.filter and s.phrase_filter ? | |
s.q '' # override / merge s.query and s.phrase_query ? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A hash modifier that creates method readers from key names. | |
# NOTE: reader methods are created recursively. | |
# The method names are the same as the key names, | |
# except that the values are snake-cased, for example: | |
# - QTime -> q_time | |
# - debugQuery -> debug_query | |
# | |
class RSolr::Ext::HashMethodizer | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/blacklight.rb | |
# Rails will load this file once during the boot/start-up process | |
# http://ryandaigle.com/articles/2007/2/23/what-s-new-in-edge-rails-stop-littering-your-evnrionment-rb-with-custom-initializations | |
# | |
# Access the blacklight config from anywhere, like this: Blacklight.config[:solr][:url] | |
# SHARED | |
Blacklight.configure do |config| | |
# The basic solr field mapping | |
config[:display_fields] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will execute the Git revision parsing on the *remote* server rather than locally | |
# from "filmprog" on #capistrano/irc.freenode.net | |
set :real_revision, lambda { source.query_revision(revision) { |cmd| capture(cmd) } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A module to help marc related solr documents | |
# | |
# Example: | |
# docs.each{|d| d.extend(SolrMARCDocument) if d[:marc_display] } | |
# | |
module SolrMARCDocument | |
def marc | |
@marc ||= ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails action | |
def in_bg | |
pid = fork { | |
10.times do |i| | |
puts "WAITING .... #{i}" | |
sleep 1.0 | |
end | |
} | |
Process.detach(pid) | |
render :text=>pid.to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ExtendedMeta | |
def extended_by | |
ancestors = class << self; ancestors end | |
ancestors.select { |mod| mod.class == Module } - [ Object, Kernel ] | |
end | |
# just like kind_of? but can use a string instead of a module/constant | |
def extended_by?(mod) | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solr = RSolr.connect | |
solr.extend RSolr::Ext::Connection | |
full_response = solr.find({:q=>'*:*'}, :response=>true) | |
one_doc = solr.find({:q=>'blah'}, :first=>true) | |
one_doc = solr.find_by_id(10) |
OlderNewer