pduey-sunspot_rails 1.2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/History.txt +54 -0
- data/LICENSE +18 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +282 -0
- data/Rakefile +18 -0
- data/TESTING.md +35 -0
- data/TODO +8 -0
- data/VERSION.yml +4 -0
- data/dev_tasks/rdoc.rake +24 -0
- data/dev_tasks/release.rake +4 -0
- data/dev_tasks/spec.rake +27 -0
- data/dev_tasks/todo.rake +4 -0
- data/generators/sunspot/sunspot_generator.rb +9 -0
- data/generators/sunspot/templates/sunspot.yml +18 -0
- data/install.rb +1 -0
- data/lib/generators/sunspot_rails.rb +9 -0
- data/lib/generators/sunspot_rails/install/install_generator.rb +13 -0
- data/lib/generators/sunspot_rails/install/templates/config/sunspot.yml +17 -0
- data/lib/sunspot/rails.rb +63 -0
- data/lib/sunspot/rails/adapters.rb +83 -0
- data/lib/sunspot/rails/configuration.rb +323 -0
- data/lib/sunspot/rails/init.rb +5 -0
- data/lib/sunspot/rails/log_subscriber.rb +33 -0
- data/lib/sunspot/rails/railtie.rb +36 -0
- data/lib/sunspot/rails/railties/controller_runtime.rb +36 -0
- data/lib/sunspot/rails/request_lifecycle.rb +36 -0
- data/lib/sunspot/rails/searchable.rb +420 -0
- data/lib/sunspot/rails/server.rb +173 -0
- data/lib/sunspot/rails/solr_instrumentation.rb +20 -0
- data/lib/sunspot/rails/solr_logging.rb +62 -0
- data/lib/sunspot/rails/spec_helper.rb +26 -0
- data/lib/sunspot/rails/stub_session_proxy.rb +142 -0
- data/lib/sunspot/rails/tasks.rb +66 -0
- data/lib/sunspot_rails.rb +12 -0
- data/spec/configuration_spec.rb +173 -0
- data/spec/model_lifecycle_spec.rb +63 -0
- data/spec/model_spec.rb +478 -0
- data/spec/rails2/.gitignore +2 -0
- data/spec/rails2/Gemfile +15 -0
- data/spec/rails2/Rakefile +17 -0
- data/spec/rails2/app/controllers/application.rb +10 -0
- data/spec/rails2/app/controllers/application_controller.rb +10 -0
- data/spec/rails2/app/controllers/posts_controller.rb +6 -0
- data/spec/rails2/app/models/author.rb +8 -0
- data/spec/rails2/app/models/blog.rb +12 -0
- data/spec/rails2/app/models/location.rb +2 -0
- data/spec/rails2/app/models/photo_post.rb +2 -0
- data/spec/rails2/app/models/post.rb +11 -0
- data/spec/rails2/app/models/post_with_auto.rb +10 -0
- data/spec/rails2/app/models/post_with_conditional_index.rb +13 -0
- data/spec/rails2/app/models/post_with_default_scope.rb +11 -0
- data/spec/rails2/config/boot.rb +116 -0
- data/spec/rails2/config/database.yml +4 -0
- data/spec/rails2/config/environment.rb +41 -0
- data/spec/rails2/config/environments/development.rb +27 -0
- data/spec/rails2/config/environments/test.rb +27 -0
- data/spec/rails2/config/initializers/new_rails_defaults.rb +19 -0
- data/spec/rails2/config/initializers/session_store.rb +15 -0
- data/spec/rails2/config/preinitializer.rb +19 -0
- data/spec/rails2/config/routes.rb +43 -0
- data/spec/rails2/config/sunspot.yml +19 -0
- data/spec/rails2/db/schema.rb +27 -0
- data/spec/rails2/script/console +3 -0
- data/spec/rails3/.gitignore +4 -0
- data/spec/rails3/Gemfile +15 -0
- data/spec/rails3/README +281 -0
- data/spec/rails3/Rakefile +7 -0
- data/spec/rails3/app/controllers/application.rb +4 -0
- data/spec/rails3/app/controllers/application_controller.rb +4 -0
- data/spec/rails3/app/controllers/posts_controller.rb +6 -0
- data/spec/rails3/app/models/author.rb +8 -0
- data/spec/rails3/app/models/blog.rb +12 -0
- data/spec/rails3/app/models/location.rb +2 -0
- data/spec/rails3/app/models/photo_post.rb +2 -0
- data/spec/rails3/app/models/post.rb +11 -0
- data/spec/rails3/app/models/post_with_auto.rb +10 -0
- data/spec/rails3/app/models/post_with_conditional_index.rb +13 -0
- data/spec/rails3/app/models/post_with_default_scope.rb +11 -0
- data/spec/rails3/config.ru +4 -0
- data/spec/rails3/config/application.rb +46 -0
- data/spec/rails3/config/boot.rb +13 -0
- data/spec/rails3/config/database.yml +22 -0
- data/spec/rails3/config/environment.rb +5 -0
- data/spec/rails3/config/environments/development.rb +19 -0
- data/spec/rails3/config/environments/test.rb +19 -0
- data/spec/rails3/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3/config/initializers/inflections.rb +10 -0
- data/spec/rails3/config/initializers/mime_types.rb +5 -0
- data/spec/rails3/config/initializers/new_rails_defaults.rb +19 -0
- data/spec/rails3/config/initializers/secret_token.rb +7 -0
- data/spec/rails3/config/initializers/session_store.rb +8 -0
- data/spec/rails3/config/locales/en.yml +5 -0
- data/spec/rails3/config/routes.rb +59 -0
- data/spec/rails3/config/sunspot.yml +19 -0
- data/spec/rails3/db/schema.rb +27 -0
- data/spec/rails3/script/console +3 -0
- data/spec/rails3/script/rails +6 -0
- data/spec/rails3/solr/.gitignore +1 -0
- data/spec/rails3/solr/conf/elevate.xml +36 -0
- data/spec/rails3/solr/conf/schema.xml +238 -0
- data/spec/rails3/solr/conf/solrconfig.xml +938 -0
- data/spec/rails3/solr/conf/spellings.txt +2 -0
- data/spec/rails3/solr/conf/stopwords.txt +58 -0
- data/spec/rails3/solr/conf/synonyms.txt +31 -0
- data/spec/rails3/solr/lib/lucene-spatial-2.9.1.jar +0 -0
- data/spec/rails3/solr/lib/solr-spatial-light-0.0.6.jar +0 -0
- data/spec/request_lifecycle_spec.rb +61 -0
- data/spec/schema.rb +27 -0
- data/spec/server_spec.rb +37 -0
- data/spec/session_spec.rb +24 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/stub_session_proxy_spec.rb +122 -0
- data/sunspot_rails.gemspec +44 -0
- metadata +322 -0
data/spec/rails2/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'rails', '~> 2.3.14'
|
4
|
+
gem 'sqlite3-ruby', '~> 1.3.1'
|
5
|
+
|
6
|
+
gem 'sunspot', :path => File.expand_path('../../../../sunspot', __FILE__)
|
7
|
+
gem 'sunspot_solr', :path => File.expand_path('../../../../sunspot_solr', __FILE__)
|
8
|
+
gem 'sunspot_rails', :path => File.expand_path('../../..', __FILE__)
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rspec-rails', '~> 1.3.4'
|
12
|
+
gem 'ruby-debug19', :require => nil, :platforms => :mri_19
|
13
|
+
gem 'test-unit', '1.2.3', :platforms => :mri_19
|
14
|
+
gem 'ruby-debug', :require => nil, :platforms => :mri_18
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rdoc/task'
|
9
|
+
require 'tasks/rails'
|
10
|
+
|
11
|
+
# Try to load gem tasks. rake gems:install fails if these gems have not yet been
|
12
|
+
# installed because the Rakefile falls over when it tries to require their tasks.
|
13
|
+
begin
|
14
|
+
require 'sunspot/rails/tasks'
|
15
|
+
rescue Exception => e
|
16
|
+
puts "Warning, couldn't load gem tasks: #{e.message}! Skipping..."
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
+
|
8
|
+
# Scrub sensitive parameters from your log
|
9
|
+
# filter_parameter_logging :password
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
+
|
8
|
+
# Scrub sensitive parameters from your log
|
9
|
+
# filter_parameter_logging :password
|
10
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Blog < ActiveRecord::Base
|
2
|
+
has_many :posts
|
3
|
+
has_many :comments, :through => :posts
|
4
|
+
|
5
|
+
searchable :include => { :posts => :author } do
|
6
|
+
string :subdomain
|
7
|
+
text :name
|
8
|
+
end
|
9
|
+
|
10
|
+
# Make sure that includes are added to with multiple searchable calls
|
11
|
+
searchable(:include => :comments) {}
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class PostWithConditionalIndex < ActiveRecord::Base
|
2
|
+
def self.table_name
|
3
|
+
'posts'
|
4
|
+
end
|
5
|
+
|
6
|
+
searchable :auto_index => false, :auto_remove => false, :if => :title_is_present do
|
7
|
+
string :title
|
8
|
+
end
|
9
|
+
|
10
|
+
def title_is_present
|
11
|
+
title.present?
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.class_eval do
|
40
|
+
def load_gems
|
41
|
+
@bundler_loaded ||= Bundler.require(:default, Rails.env)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Rails::Initializer.run(:set_load_path)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class VendorBoot < Boot
|
50
|
+
def load_initializer
|
51
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
52
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
53
|
+
Rails::GemDependency.add_frozen_gem_path
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class GemBoot < Boot
|
58
|
+
def load_initializer
|
59
|
+
self.class.load_rubygems
|
60
|
+
load_rails_gem
|
61
|
+
require 'initializer'
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_rails_gem
|
65
|
+
if version = self.class.gem_version
|
66
|
+
gem 'rails', version
|
67
|
+
else
|
68
|
+
gem 'rails'
|
69
|
+
end
|
70
|
+
rescue Gem::LoadError => load_error
|
71
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
|
75
|
+
class << self
|
76
|
+
def rubygems_version
|
77
|
+
Gem::RubyGemsVersion rescue nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def gem_version
|
81
|
+
if defined? RAILS_GEM_VERSION
|
82
|
+
RAILS_GEM_VERSION
|
83
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
84
|
+
ENV['RAILS_GEM_VERSION']
|
85
|
+
else
|
86
|
+
parse_gem_version(read_environment_rb)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def load_rubygems
|
91
|
+
require 'rubygems'
|
92
|
+
min_version = '1.3.1'
|
93
|
+
unless rubygems_version >= min_version
|
94
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
|
98
|
+
rescue LoadError
|
99
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
100
|
+
exit 1
|
101
|
+
end
|
102
|
+
|
103
|
+
def parse_gem_version(text)
|
104
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
def read_environment_rb
|
109
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# All that for this:
|
116
|
+
Rails.boot!
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
2
|
+
|
3
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
4
|
+
# RAILS_GEM_VERSION = ENV['RAILS_GEM_VERSION'] || '2.3.3' unless defined? RAILS_GEM_VERSION
|
5
|
+
|
6
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
7
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
8
|
+
|
9
|
+
Rails::Initializer.run do |config|
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Add additional load paths for your own custom dirs
|
15
|
+
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
16
|
+
|
17
|
+
# Specify gems that this application depends on and have them installed with rake gems:install
|
18
|
+
# config.gem "bj"
|
19
|
+
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
20
|
+
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
21
|
+
# config.gem "aws-s3", :lib => "aws/s3"
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
26
|
+
|
27
|
+
# Skip frameworks you're not going to use. To use Rails without a database,
|
28
|
+
# you must remove the Active Record framework.
|
29
|
+
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
30
|
+
|
31
|
+
# Activate observers that should always be running
|
32
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
33
|
+
|
34
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
35
|
+
# Run "rake -D time" for a list of tasks for finding time zone names.
|
36
|
+
config.time_zone = 'UTC'
|
37
|
+
|
38
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
39
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
40
|
+
# config.i18n.default_locale = :de
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
config.cache_classes = true
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.action_controller.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Disable request forgery protection in test environment
|
17
|
+
config.action_controller.allow_forgery_protection = false
|
18
|
+
|
19
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
20
|
+
# The :test delivery method accumulates sent emails in the
|
21
|
+
# ActionMailer::Base.deliveries array.
|
22
|
+
config.action_mailer.delivery_method = :test
|
23
|
+
|
24
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
25
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
26
|
+
# like if you have constraints or database-specific column types
|
27
|
+
# config.active_record.schema_format = :sql
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
config.cache_classes = true
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.action_controller.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Disable request forgery protection in test environment
|
17
|
+
config.action_controller.allow_forgery_protection = false
|
18
|
+
|
19
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
20
|
+
# The :test delivery method accumulates sent emails in the
|
21
|
+
# ActionMailer::Base.deliveries array.
|
22
|
+
config.action_mailer.delivery_method = :test
|
23
|
+
|
24
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
25
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
26
|
+
# like if you have constraints or database-specific column types
|
27
|
+
# config.active_record.schema_format = :sql
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# These settings change the behavior of Rails 2 apps and will be defaults
|
4
|
+
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
5
|
+
|
6
|
+
if defined?(ActiveRecord)
|
7
|
+
# Include Active Record class name as root for JSON serialized output.
|
8
|
+
ActiveRecord::Base.include_root_in_json = true
|
9
|
+
|
10
|
+
# Store the full class name (including module namespace) in STI type column.
|
11
|
+
ActiveRecord::Base.store_full_sti_class = true
|
12
|
+
end
|
13
|
+
|
14
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
15
|
+
ActiveSupport.use_standard_json_time_format = true
|
16
|
+
|
17
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
18
|
+
# if you're including raw json in an HTML page.
|
19
|
+
ActiveSupport.escape_html_entities_in_json = false
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying cookie session data integrity.
|
4
|
+
# If you change this key, all old sessions will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
ActionController::Base.session = {
|
8
|
+
:key => '_mock_app_session',
|
9
|
+
:secret => 'a2ddf56c7d642f2075a5d466eff55556c20d13415aff5156740ac82848c3c586711fde0e52f4834727816d08b2d13f3da7b6c7587d789cebe6081ee1a7fec943'
|
10
|
+
}
|
11
|
+
|
12
|
+
# Use the database for sessions instead of the cookie-based default,
|
13
|
+
# which shouldn't be used to store highly confidential information
|
14
|
+
# (create the session table with "rake db:sessions:create")
|
15
|
+
# ActionController::Base.session_store = :active_record_store
|
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require "rubygems"
|
3
|
+
require "bundler"
|
4
|
+
rescue LoadError
|
5
|
+
raise "Could not load the bundler gem. Install it with `gem install bundler`"
|
6
|
+
end
|
7
|
+
|
8
|
+
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
|
9
|
+
raise RuntimeError, "Your bundler version is too old. " +
|
10
|
+
"Run `gem install bundler` to upgrade."
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
|
15
|
+
Bundler.setup
|
16
|
+
rescue Bundler::GemNotFound
|
17
|
+
raise RuntimeError, "Bundler couldn't find some gems. " +
|
18
|
+
"Did you run `bundle install`?"
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
|
4
|
+
# Sample of regular route:
|
5
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
6
|
+
# Keep in mind you can assign values other than :controller and :action
|
7
|
+
|
8
|
+
# Sample of named route:
|
9
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
10
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
11
|
+
|
12
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
13
|
+
# map.resources :products
|
14
|
+
|
15
|
+
# Sample resource route with options:
|
16
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
17
|
+
|
18
|
+
# Sample resource route with sub-resources:
|
19
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
20
|
+
|
21
|
+
# Sample resource route with more complex sub-resources
|
22
|
+
# map.resources :products do |products|
|
23
|
+
# products.resources :comments
|
24
|
+
# products.resources :sales, :collection => { :recent => :get }
|
25
|
+
# end
|
26
|
+
|
27
|
+
# Sample resource route within a namespace:
|
28
|
+
# map.namespace :admin do |admin|
|
29
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
30
|
+
# admin.resources :products
|
31
|
+
# end
|
32
|
+
|
33
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
34
|
+
# map.root :controller => "welcome"
|
35
|
+
|
36
|
+
# See how all your routes lay out with "rake routes"
|
37
|
+
|
38
|
+
# Install the default routes as the lowest priority.
|
39
|
+
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
40
|
+
# consider removing the them or commenting them out if you're using named routes and resources.
|
41
|
+
|
42
|
+
map.resources :posts, :only => :create
|
43
|
+
end
|