Skip to content

Instantly share code, notes, and snippets.

View DAddYE's full-sized avatar

Davide D'Agostino DAddYE

  • Uber
  • San Francisco
View GitHub Profile
renderers:
boolean: &boolean_renderer
renderer: | __js__
function(v, p, r){
var tmp = (v!=undefined && v!='');
return Ext.util.Format.boolRenderer(tmp, p, r)
}
editors:
checkbox: &checkbox
error do
exception = request.env['sinatra.error']
Hoptoad::Notifier.send_error exception, params, request.env if %w(staging production).include?(ENV['RACK_ENV'])
erb :five_hundred
end
# Install Padrino
gem install padrino --no-ri --no-rdoc
# Put this in your shell for create in few seconds a Padrino Project with Padrino Admin
padrino-gen project foo -d activerecord -b; cd foo; padrino-gen admin; padrino rake ar:migrate; padrino rake seed; padrino start
# Defines our constants
PADRINO_ENV = ENV["PADRINO_ENV"] ||= ENV["RACK_ENV"] ||= "development" unless defined?(PADRINO_ENV)
PADRINO_ROOT = File.dirname(__FILE__) + '/..' unless defined? PADRINO_ROOT
begin
# Require the preresolved locked set of gems.
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Fallback on doing the resolve at runtime.
require 'rubygems'
##
# This is an exception notifier for Padrino::Application with
# redmine bonus feature.
#
# ==== Usage
#
# class MyApp < Padrino::Application
# register ExceptionNotifier
# set :exceptions_from, "errors@localhost.local"
# set :exceptions_to, "foo@bar.local"
##
# This is an extension for ActiveRecord where if I had:
#
# post.description_ru = "I'm Russian"
# post.description_en = "I'm English"
# post.description_it = "I'm Italian"
#
# with this extension if I had set:
#
# I18n.locale = :it
##
# This extension give to padrino the ability to change
# their locale inspecting.
#
# ==== Usage
#
# class MyApp < Padrino::Application
# register AutoLocale
# set :locales, [:en, :ru, :de] # First locale is the default locale
# end
##
# Rspec way routes and context filters
#
MyApp.context :frontend do
context :posts do
get :index do; ... end
get :show, :with => :id do; ... end
end
# Before/After filters in padrino
SimpleApp.controllers :posts do
# These are public actions, no authentication required
get :index do; ... end;
get :show, :with => :id do; ... end;
# These actions require being authenticated
# Variant 1