-
Has routes.rb like rails, Padrino not
-
Merb define controllers in class and routes in def like rails, Padrino use sinatra blocks.
-
Merb has not admin, Padrino has some thing like django-admin
-
Merb has slices that are 1:1 equals to Rails Engines, Padrino apply the same concept of DJango where you build a project and then apps.
-
A full merb stack require some like 56 gems Padrino if Im not wrong 16 gems.
-
Padrino has full support to I18n like rails/django, Merb not
-
Merb has DataMapper as preferred orm, Rails ActiveRecord, Padrino “NONE”
-
Our rendering is only an enhanced version of Sinatra rendering (but Merb didn’t support haml :foo, erb :bar)
This file contains hidden or 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
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 |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
$ padrino-gen project sample_blog -t shoulda -e haml -c sass -s jquery -d activerecord | |
create | |
create config/apps.rb | |
create config/boot.rb | |
create config.ru | |
create public/favicon.ico | |
create .gitignore | |
create public/images | |
create public/javascripts | |
create public/stylesheets |
This file contains hidden or 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
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord, :dev => true | |
#default routes | |
APP_INIT = <<-APP | |
get "/" do | |
"Hello World!" | |
end | |
get :about, :map => '/about_us' do | |
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!" |
This file contains hidden or 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
#!/usr/bin/ruby | |
# This script installs to /usr/local only. To install elsewhere you can just | |
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like. | |
module Tty extend self | |
def blue; bold 34; end | |
def white; bold 39; end | |
def red; underline 31; end | |
def reset; escape 0; end | |
def bold n; escape "1;#{n}" end |
This file contains hidden or 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 EventMachine | |
def self.system3(cmd, *args, &cb) | |
cb ||= args.pop if args.last.is_a? Proc | |
init = args.pop if args.last.is_a? Proc | |
# merge remaining arguments into the command | |
cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ') | |
new_stderr = $stderr.dup |
This file contains hidden or 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
require "fiber" | |
f1 = Fiber.new do |f2| | |
while true | |
puts "A" | |
sleep 2 | |
f2.transfer | |
end | |
end |
This file contains hidden or 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/source_maps.rb | |
if Rails.env.development? | |
module CoffeeScript | |
class SourceMapError < StandardError; end; | |
class << self | |
def compile script, options | |
script = script.read if script.respond_to?(:read) |
OlderNewer