-
-
Save johnpaulashenfelter/870d25ce9ea02b163ef3747dd5fd4755 to your computer and use it in GitHub Desktop.
Revisions
-
shawndrost revised this gist
Jan 17, 2012 . 2 changed files with 30 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,39 @@ # the new and improved one-file rails app -- now including require "action_controller/railtie" class Tester < Rails::Application config.session_store :cookie_store, :key => '_rails_session' config.secret_token = '095f674153982a9ce59914b561f4522a' end class UsersController < ActionController::Base def current render text: current_user.server_id end def create @u = User.create(params[:user]) @u.create_remotely! session[:user_id] = @u.id render text: "good!" end end require 'sqlite3' db_file = File.join(File.dirname(__FILE__), 'test.sqlite3') db = SQLite3::Database.new( db_file ) db.execute( "drop table users;" ) rescue nil # maybe it didn't exist! db.execute( "create table users (id integer primary key autoincrement, email varchar(100), server_id integer);" ) require 'active_record' ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => db_file) class User < ActiveRecord::Base include Whoami::Rails::ActiveRecord end Tester.routes.draw do root to: 'users#current' match '/users/current' => 'users#current' resources :users 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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ require './application' run Tester -
dgb created this gist
Nov 21, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ require "action_controller/railtie" class Application < Rails::Application config.session_store :cookie_store, :key => '_rails_session' config.secret_token = '095f674153982a9ce59914b561f4522a' end class PagesController < ActionController::Base def index render :text => "Hello, world!" end end Application.routes.draw do get '/' => 'pages#index' 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ require './application' run Application