Skip to content

Instantly share code, notes, and snippets.

View dariocravero's full-sized avatar

Darío Javier Cravero dariocravero

View GitHub Profile
Wakupdude.controllers :dudes do
set :haml, {:format => :html5 }
# get :index do
# render "dudes/index"
# end
get :all, :map => "/" do
@dudes = Dude.all()
render "dudes/list"
# Small reformats
if !absolute_map
path.gsub!(%r{/?index/?}, '') # Remove index path
path[0,0] = "/" unless path =~ %r{^\(?/} # Paths must start with a /
path.sub!(%r{/(\))?$}, '\\1') # Remove latest trailing delimiter
path.gsub!(/\/(\(\.|$)/, '\\1') # Remove trailing slashes
end
if !absolute_map or !@_map.blank?
# Add any controller level map to the front of the path
path = "#{@_map}/#{path}".squeeze('/')
# Small reformats
path.gsub!(%r{/?index/?}, '') # Remove index path
path[0,0] = "/" unless path =~ %r{^\(?/} # Paths must start with a /
path.sub!(%r{/(\))?$}, '\\1') # Remove latest trailing delimiter
path.gsub!(/\/(\(\.|$)/, '\\1') # Remove trailing slashes
end
In:
http://github.com/dariocravero/padrino-framework/blob/map-forward-slash/padrino-core/test/test_routing.rb#L502
should 'apply maps' do
mock_app do
controllers :admin do
get(:index, :map => "/"){ "index" }
get(:show, :with => :id, :map => "/show"){ "show #{params[:id]}" }
get(:edit, :map => "/edit/:id/product"){ "edit #{params[:id]}" }
daris@daris:~/dev/projects/gci_onlinetest$ padrino console
=> Loading development console (Padrino v.0.9.18)
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- readline (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/daris/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/daris/.rvm/gems/ruby-1.9.2-p0/gems/padrino-core-0.9.18/lib/padrino-core/cli/base.rb:59:in `console'
from /home/daris/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.4/lib/thor/task.rb:22:in `run'
from /home/daris/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.4/lib/thor/invocation.rb:118:in `invoke_task'
class CardVariation
includes Mongoid::Document
references_one :language
field :name
end
class Language
includes Mongoid::Document
referenced_in :card_variation
@dariocravero
dariocravero / gist:770892
Created January 8, 2011 14:46
Padrino recipes ssl error
daris@daris:~/Documents/dev/projects/wheresmymoney$ padrino g plugin coffee
=> Located unlocked Gemfile for development
apply https://github.com/padrino/padrino-recipes/raw/master/plugins/coffee_plugin.rb
/home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677:in `connect'
from /home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from /home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:626:in `start'
from /home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/open-uri.rb:306:in `open_http'
from /home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/open-uri.rb:769:in `buffer_open'
from /home/daris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/open-uri.rb:203:in `block in open_loop'
daris@daris:~/Documents/dev/projects/wheresmymoney$ padrino g plugin coffee
=> Located unlocked Gemfile for development
apply https://github.com/padrino/padrino-recipes/raw/master/plugins/coffee_plugin.rb
/home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/net/http.rb:586:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/net/http.rb:586:in `connect'
from /home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/net/http.rb:553:in `do_start'
from /home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/net/http.rb:542:in `start'
from /home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/open-uri.rb:242:in `open_http'
from /home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'
from /home/daris/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
@dariocravero
dariocravero / gist:892338
Created March 29, 2011 13:20
Mysql gem should be ruby-mysql when using ruby 1.9.x
We couldn’t find that file to show.
@dariocravero
dariocravero / gist:1078101
Created July 12, 2011 14:38
error while rendering an email with a layout with padrino mailer
ruby-1.9.2-p180 :011 > PapercrowdApp::deliver(:reviewers, :invitation_email_existing_user, "Dario", "dario@starlight.ie", "http://www.exordo.com")
DEBUG - [12/Jul/2011 15:35:28] "Resolving layout /viewslayouts/email"
NameError: undefined local variable or method `name' for #<Mail::Message:0x00000105af2340>
from /Users/daris/.rvm/gems/ruby-1.9.2-p180/gems/mail-2.3.0/lib/mail/message.rb:1289:in `method_missing'
from /Users/daris/Documents/starlight/exordo/app_ruby/trunk/app/views/mailers/reviewers/invitation_email_existing_user.haml:1:in `evaluate_source'
from /Users/daris/.rvm/gems/ruby-1.9.2-p180/gems/tilt-1.3.2/lib/tilt/template.rb:209:in `instance_eval'
from /Users/daris/.rvm/gems/ruby-1.9.2-p180/gems/tilt-1.3.2/lib/tilt/template.rb:209:in `evaluate_source'
from /Users/daris/.rvm/gems/ruby-1.9.2-p180/gems/tilt-1.3.2/lib/tilt/template.rb:144:in `cached_evaluate'
from /Users/daris/.rvm/gems/ruby-1.9.2-p180/gems/tilt-1.3.2/lib/tilt/template.rb:127:in `evaluate'
from /Users/daris/.rvm/gems/ruby-1.9.2-p