2012-05-20 10:30:19 -04:00
|
|
|
# require 'rails/all'
|
|
|
|
require 'action_controller/railtie'
|
|
|
|
require 'action_view/railtie'
|
|
|
|
|
|
|
|
require 'fake_app/active_record/config' if defined? ActiveRecord
|
|
|
|
require 'fake_app/mongoid/config' if defined? Mongoid
|
|
|
|
# config
|
|
|
|
app = Class.new(Rails::Application)
|
|
|
|
app.config.secret_token = '3b7cd727ee24e8444053437c36cc66c4'
|
|
|
|
app.config.session_store :cookie_store, :key => '_myapp_session'
|
|
|
|
app.config.active_support.deprecation = :log
|
2013-06-25 21:07:44 -04:00
|
|
|
app.config.eager_load = false
|
2015-12-18 16:50:55 -05:00
|
|
|
# Rails.root
|
2012-05-24 02:20:26 -04:00
|
|
|
app.config.root = File.dirname(__FILE__)
|
2012-05-20 10:30:19 -04:00
|
|
|
Rails.backtrace_cleaner.remove_silencers!
|
|
|
|
app.initialize!
|
|
|
|
|
2013-11-09 15:17:32 -05:00
|
|
|
# routes
|
|
|
|
app.routes.draw do
|
|
|
|
resources :users
|
2014-05-21 20:07:29 -04:00
|
|
|
resources :addresses do
|
|
|
|
get 'page/:page', :action => :index, :on => :collection
|
|
|
|
end
|
2013-11-09 15:17:32 -05:00
|
|
|
end
|
|
|
|
|
2012-05-20 10:30:19 -04:00
|
|
|
#models
|
|
|
|
require 'fake_app/active_record/models' if defined? ActiveRecord
|
|
|
|
require 'fake_app/mongoid/models' if defined? Mongoid
|
|
|
|
|
|
|
|
# controllers
|
|
|
|
class ApplicationController < ActionController::Base; end
|
|
|
|
class UsersController < ApplicationController
|
|
|
|
def index
|
|
|
|
@users = User.page params[:page]
|
|
|
|
render :inline => <<-ERB
|
|
|
|
<%= @users.map(&:name).join("\n") %>
|
|
|
|
<%= paginate @users %>
|
|
|
|
ERB
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if defined? ActiveRecord
|
|
|
|
class AddressesController < ApplicationController
|
|
|
|
def index
|
|
|
|
@addresses = User::Address.page params[:page]
|
|
|
|
render :inline => <<-ERB
|
|
|
|
<%= @addresses.map(&:street).join("\n") %>
|
|
|
|
<%= paginate @addresses %>
|
|
|
|
ERB
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# helpers
|
|
|
|
Object.const_set(:ApplicationHelper, Module.new)
|