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 'sinatra' | |
| require 'warden' | |
| class YourApp < Sinatra::Application | |
| get "/" do | |
| erb 'index'.to_sym | |
| end | |
| get "/protected_pages" do |
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
| development: &defaults | |
| # Configure available database sessions. (required) | |
| sessions: | |
| # Defines the default session. (required) | |
| default: &default_session | |
| # Defines the name of the default database that Mongoid can connect to. | |
| # (required). | |
| database: delight_development | |
| # Provides the hosts the default session can connect to. Must be an array | |
| # of host:port pairs. (required) |
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
| gem 'sinatra' | |
| group :development,:test do | |
| gem 'rspec' | |
| gem 'rack-test' | |
| 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
| require 'something/to/be/required' | |
| class Sinatra::Base | |
| @@prepared = nil | |
| def self.onion_core | |
| onion = prototype | |
| loop do | |
| onion = onion.instance_variable_get('@app') | |
| return onion if onion.class == self || onion.nil? |
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 'bcrypt' | |
| class User | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| include BCrypt | |
| attr_accessor :password, :password_confirmation | |
| attr_protected :password_hash | |
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
| * Review this article and add new steps as needed: http://blog.therubymug.com/blog/2010/05/20/the-install-osx.html |
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
| Warden::Manager.serialize_into_session{|user| user.id } | |
| Warden::Manager.serialize_from_session{|id| User.get(id) } | |
| Warden::Manager.before_failure do |env,opts| | |
| # Sinatra is very sensitive to the request method | |
| # since authentication could fail on any type of method, we need | |
| # to set it for the failure app so it is routed to the correct block | |
| env['REQUEST_METHOD'] = "POST" | |
| end | |