Skip to content

Instantly share code, notes, and snippets.

@watsoncj
Created July 19, 2011 20:53
Show Gist options
  • Save watsoncj/1093686 to your computer and use it in GitHub Desktop.
Save watsoncj/1093686 to your computer and use it in GitHub Desktop.
% cat app/helpers/retailer_helper.rb
# Helper methods defined here can be accessed in any controller or view in the application
Cc.helpers do
def messages
msg=""
if flash.has?(:err) or flash.has?(:ok)
msg<<"<div id='message'>"
if flash.has? :err
msg<<"<div class='err'>#{flash[:err]}</div>"
end
if flash.has? :ok
msg<<"<div class='ok'>#{flash[:ok]}</div>"
end
msg<<"</div>"
end
flash.flag!
flash.sweep!
return msg
end
def header_link(title, path)
"<li class='#{"active" if request.route==path}'><a href='#{path}'>#{title}</a></li>"
end
end
% cat app/views/email.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
....SNIP....
<% if @success %>
<p>Thanks! You should hear from us soon!</p>
<% else %>
<%= messages() %>
....SNIP....
</html>
$ cat config.ru
#!/usr/bin/env rackup
# encoding: utf-8
# This file can be used to start Padrino,
# just execute it from the command line.
require File.expand_path("../config/boot.rb", __FILE__)
run Padrino.application
$ cat log/production.log
ERROR - [19/Jul/2011 14:11:01] "NoMethodError - undefined method `messages' for #<Cc:0xa3435dc>:
/var/cleverclerk/releases/20110719183941/app/views/email.erb:42:in `evaluate_source'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.2/lib/tilt/template.rb:209:in `instance_eval'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.2/lib/tilt/template.rb:209:in `evaluate_source'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.2/lib/tilt/template.rb:144:in `cached_evaluate'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.2/lib/tilt/template.rb:127:in `evaluate'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.2/lib/tilt/template.rb:76:in `render'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:563:in `render'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application.rb:255:in `render'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/rendering.rb:149:in `render'
/var/cleverclerk/releases/20110719183941/app/app.rb:75:in `block in <class:Cc>'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:486:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:486:in `block in route'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:724:in `instance_eval'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:724:in `route_eval'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `block (2 levels) in process_destination_path'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `catch'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `block in process_destination_path'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:22:in `instance_eval'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:22:in `process_destination_path'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router/node/root.rb:81:in `block in []'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router/node/root.rb:71:in `catch'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router/node/root.rb:71:in `[]'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router/node/root.rb:12:in `[]'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router.rb:110:in `block in call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router.rb:110:in `catch'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/http_router-0.8.11/lib/http_router.rb:110:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:796:in `route!'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:785:in `dispatch!'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:644:in `block in call!'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `instance_eval'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `block in invoke'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `catch'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `invoke'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:644:in `call!'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:629:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-flash-0.1.2/lib/rack/flash.rb:147:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sass-3.1.4/lib/sass/plugin/rack.rb:54:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.0/lib/rack/session/abstract/id.rb:195:in `context'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.0/lib/rack/session/abstract/id.rb:190:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.0/lib/rack/session/abstract/id.rb:195:in `context'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.0/lib/rack/session/abstract/id.rb:190:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.0/lib/rack/head.rb:9:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.0/lib/rack/methodoverride.rb:24:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:1272:in `block in call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:1303:in `synchronize'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.2.6/lib/sinatra/base.rb:1272:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:71:in `block in call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:64:in `each'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:64:in `call'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:205:in `start_request_handler'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:170:in `block in handle_spawn_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:479:in `safe_fork'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:165:in `handle_spawn_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:180:in `start'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/home/cwatson/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/helper-scripts/passenger-spawn-server:99:in `<main>'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment