Skip to content

Instantly share code, notes, and snippets.

@fishman
Created September 13, 2012 16:03

Revisions

  1. @josevalim josevalim revised this gist Mar 8, 2012. No changes.
  2. @josevalim josevalim revised this gist Mar 8, 2012. 2 changed files with 17 additions and 5 deletions.
    5 changes: 3 additions & 2 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    source :rubygems

    # We are not loading Active Record, nor the Assets Pipeline, etc.
    # You can do this by simply replacing the rails gem by its parts.
    # We are not loading Active Record, nor Active Resources etc.
    # We can do this in any app by simply replacing the rails gem
    # by the parts we want to use.
    gem "actionpack", "~> 3.2"
    gem "railties", "~> 3.2"
    gem "tzinfo"
    17 changes: 14 additions & 3 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,18 @@
    #
    # And access:
    #
    # http://localhost:3000/hello/world
    # http://localhost:3000/hello/world
    #
    # We are using Bundler in this example, but we could also
    # have used rubygems:
    #
    # require "rubygems"
    #
    # gem "actionpack"
    # gem "railties"
    #
    # require "rails"
    # require "rails/all"

    # The following lines should come as no surprise. Except by
    # ActionController::Metal, it follows the same structure of
    @@ -45,7 +56,7 @@ class HelloController < ActionController::Metal
    end
    end

    # Initialize the app
    # Initialize the app (originally in config/environment.rb)
    MyApp.initialize!

    # Print the stack for fun!
    @@ -55,5 +66,5 @@ Rails.configuration.middleware.each do |middleware|
    end
    puts "run #{Rails.application.class.name}.routes"

    # Run it!
    # Run it (originally in config.ru)
    run MyApp
  3. @josevalim josevalim revised this gist Mar 8, 2012. 2 changed files with 17 additions and 8 deletions.
    10 changes: 10 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    source :rubygems

    # We are not loading Active Record, nor the Assets Pipeline, etc.
    # You can do this by simply replacing the rails gem by its parts.
    gem "actionpack", "~> 3.2"
    gem "railties", "~> 3.2"
    gem "tzinfo"

    # Let's use thin
    gem "thin"
    15 changes: 7 additions & 8 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,10 @@
    # Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
    # Be sure to have rails and thin installed.
    require "rubygems"

    # We are not loading Active Record, nor the Assets Pipeline, etc.
    # This could also be in your Gemfile.
    gem "actionpack", "~> 3.2"
    gem "railties", "~> 3.2"
    # Run this file with:
    #
    # bundle exec RAILS_ENV=production rackup -p 3000 -s thin
    #
    # And access:
    #
    # http://localhost:3000/hello/world

    # The following lines should come as no surprise. Except by
    # ActionController::Metal, it follows the same structure of
  4. @josevalim josevalim revised this gist Mar 5, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,8 @@ class MyApp < Rails::Application
    # Here you could remove some middlewares, for example
    # Rack::Lock, AD::Flash and AD::BestStandardsSupport below.
    # The remaining stack is printed on rackup (for fun!).
    # Rails 4 will have config.middleware.api_only! to get
    # rid of browser related middleware.
    config.middleware.delete "Rack::Lock"
    config.middleware.delete "ActionDispatch::Flash"
    config.middleware.delete "ActionDispatch::BestStandardsSupport"
  5. @josevalim josevalim revised this gist Mar 3, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion config.ru
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ class MyApp < Rails::Application
    config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
    end

    # This is a barebone controller. Include the modules you want, more info here:
    # This is a barebone controller. One good reference can be found here:
    # http://piotrsarnacki.com/2010/12/12/lightweight-controllers-with-rails3/
    class HelloController < ActionController::Metal
    include ActionController::Rendering
  6. @josevalim josevalim revised this gist Mar 3, 2012. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -7,20 +7,25 @@ require "rubygems"
    gem "actionpack", "~> 3.2"
    gem "railties", "~> 3.2"

    # The following lines should come as no surprise. Except by
    # ActionController::Metal, it follows the same structure of
    # config/application.rb, config/environment.rb and config.ru
    # existing in any Rails 3 app. Here they are simply in one
    # file and without the comments.
    require "rails"
    require "action_controller/railtie"
    require "rails/all"

    class MyApp < Rails::Application
    routes.append do
    match "/hello/world" => "hello#world"
    end

    # Enable cache classes
    # Enable cache classes. Production style.
    config.cache_classes = true

    # Here you could remove some middlewares, for example,
    # Here you could remove some middlewares, for example
    # Rack::Lock, AD::Flash and AD::BestStandardsSupport below.
    # The remaining stack is printed on rackup.
    # The remaining stack is printed on rackup (for fun!).
    config.middleware.delete "Rack::Lock"
    config.middleware.delete "ActionDispatch::Flash"
    config.middleware.delete "ActionDispatch::BestStandardsSupport"
  7. @josevalim josevalim revised this gist Mar 3, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -15,10 +15,12 @@ class MyApp < Rails::Application
    match "/hello/world" => "hello#world"
    end

    # Enable cache classes
    config.cache_classes = true

    # Here you could remove some middlewares, for example,
    # Rack::Lock, AD::Flash and AD::BestStandardsSupport below.
    # The remaining stack is printed on rackup. Rails 4 will
    # have a config.middleware.clear for those wishing a clear slate.
    # The remaining stack is printed on rackup.
    config.middleware.delete "Rack::Lock"
    config.middleware.delete "ActionDispatch::Flash"
    config.middleware.delete "ActionDispatch::BestStandardsSupport"
  8. @josevalim josevalim revised this gist Mar 1, 2012. 1 changed file with 10 additions and 12 deletions.
    22 changes: 10 additions & 12 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,25 @@
    # Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
    # Be sure to have rails and thin installed.
    require "rubygems"
    require "rails"

    # Let's load only action controller. If you want
    # to use active record, just require it as well.
    # We are not loading Active Record, nor the Assets Pipeline, etc.
    # This could also be in your Gemfile.
    gem "actionpack", "~> 3.2"
    gem "railties", "~> 3.2"

    require "rails"
    require "action_controller/railtie"

    class MyApp < Rails::Application
    routes.append do
    match "/hello/world" => "hello#world"
    end

    # Let's shrink the stack by removing some middlewares.
    # The remaining stack is printed below. Add or remove stuff at will.
    config.middleware.delete "ActionDispatch::Static"
    # Here you could remove some middlewares, for example,
    # Rack::Lock, AD::Flash and AD::BestStandardsSupport below.
    # The remaining stack is printed on rackup. Rails 4 will
    # have a config.middleware.clear for those wishing a clear slate.
    config.middleware.delete "Rack::Lock"
    config.middleware.delete "Rack::MethodOverride"
    config.middleware.delete "Rails::Rack::Logger"
    config.middleware.delete "ActionDispatch::DebugExceptions"
    config.middleware.delete "ActionDispatch::RequestId"
    config.middleware.delete "ActionDispatch::RemoteIp"
    config.middleware.delete "ActionDispatch::Reloader"
    config.middleware.delete "ActionDispatch::Flash"
    config.middleware.delete "ActionDispatch::BestStandardsSupport"

  9. @josevalim josevalim revised this gist Feb 29, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion config.ru
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ class MyApp < Rails::Application
    end

    # Let's shrink the stack by removing some middlewares.
    # The remaining stack is printed below.
    # The remaining stack is printed below. Add or remove stuff at will.
    config.middleware.delete "ActionDispatch::Static"
    config.middleware.delete "Rack::Lock"
    config.middleware.delete "Rack::MethodOverride"
  10. @josevalim josevalim revised this gist Feb 29, 2012. No changes.
  11. @josevalim josevalim created this gist Feb 29, 2012.
    53 changes: 53 additions & 0 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    # Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
    # Be sure to have rails and thin installed.
    require "rubygems"
    require "rails"

    # Let's load only action controller. If you want
    # to use active record, just require it as well.
    require "action_controller/railtie"

    class MyApp < Rails::Application
    routes.append do
    match "/hello/world" => "hello#world"
    end

    # Let's shrink the stack by removing some middlewares.
    # The remaining stack is printed below.
    config.middleware.delete "ActionDispatch::Static"
    config.middleware.delete "Rack::Lock"
    config.middleware.delete "Rack::MethodOverride"
    config.middleware.delete "Rails::Rack::Logger"
    config.middleware.delete "ActionDispatch::DebugExceptions"
    config.middleware.delete "ActionDispatch::RequestId"
    config.middleware.delete "ActionDispatch::RemoteIp"
    config.middleware.delete "ActionDispatch::Reloader"
    config.middleware.delete "ActionDispatch::Flash"
    config.middleware.delete "ActionDispatch::BestStandardsSupport"

    # We need a secret token for session, cookies, etc.
    config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
    end

    # This is a barebone controller. Include the modules you want, more info here:
    # http://piotrsarnacki.com/2010/12/12/lightweight-controllers-with-rails3/
    class HelloController < ActionController::Metal
    include ActionController::Rendering

    def world
    render :text => "Hello world!"
    end
    end

    # Initialize the app
    MyApp.initialize!

    # Print the stack for fun!
    puts ">> Starting Rails lightweight stack"
    Rails.configuration.middleware.each do |middleware|
    puts "use #{middleware.inspect}"
    end
    puts "run #{Rails.application.class.name}.routes"

    # Run it!
    run MyApp