render_with_missing_template 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +11 -0
- data/Gemfile.lock +101 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +32 -0
- data/Rakefile +27 -0
- data/lib/render_with_missing_template.rb +6 -0
- data/lib/render_with_missing_template/action_controller.rb +43 -0
- data/lib/render_with_missing_template/action_view.rb +60 -0
- data/lib/render_with_missing_template/missing_template_container.rb +13 -0
- data/lib/render_with_missing_template/railtie.rb +15 -0
- data/spec/controllers/render_with_missing_template_spec.rb +36 -0
- data/spec/dummy/app/controllers/application_controller.rb +26 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/config/application.rb +44 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/views/application/test.html.erb_spec.rb +9 -0
- metadata +124 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
render_with_missing_template (0.0.3)
|
5
|
+
rails (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.1)
|
12
|
+
actionpack (= 3.0.1)
|
13
|
+
mail (~> 2.2.5)
|
14
|
+
actionpack (3.0.1)
|
15
|
+
activemodel (= 3.0.1)
|
16
|
+
activesupport (= 3.0.1)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.4.1)
|
20
|
+
rack (~> 1.2.1)
|
21
|
+
rack-mount (~> 0.6.12)
|
22
|
+
rack-test (~> 0.5.4)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.1)
|
25
|
+
activesupport (= 3.0.1)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.4.1)
|
28
|
+
activerecord (3.0.1)
|
29
|
+
activemodel (= 3.0.1)
|
30
|
+
activesupport (= 3.0.1)
|
31
|
+
arel (~> 1.0.0)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.1)
|
34
|
+
activemodel (= 3.0.1)
|
35
|
+
activesupport (= 3.0.1)
|
36
|
+
activesupport (3.0.1)
|
37
|
+
arel (1.0.1)
|
38
|
+
activesupport (~> 3.0.0)
|
39
|
+
builder (2.1.2)
|
40
|
+
columnize (0.3.2)
|
41
|
+
diff-lcs (1.1.2)
|
42
|
+
erubis (2.6.6)
|
43
|
+
abstract (>= 1.0.0)
|
44
|
+
i18n (0.4.2)
|
45
|
+
linecache (0.43)
|
46
|
+
mail (2.2.9)
|
47
|
+
activesupport (>= 2.3.6)
|
48
|
+
i18n (~> 0.4.1)
|
49
|
+
mime-types (~> 1.16)
|
50
|
+
treetop (~> 1.4.8)
|
51
|
+
mime-types (1.16)
|
52
|
+
polyglot (0.3.1)
|
53
|
+
rack (1.2.1)
|
54
|
+
rack-mount (0.6.13)
|
55
|
+
rack (>= 1.0.0)
|
56
|
+
rack-test (0.5.6)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rails (3.0.1)
|
59
|
+
actionmailer (= 3.0.1)
|
60
|
+
actionpack (= 3.0.1)
|
61
|
+
activerecord (= 3.0.1)
|
62
|
+
activeresource (= 3.0.1)
|
63
|
+
activesupport (= 3.0.1)
|
64
|
+
bundler (~> 1.0.0)
|
65
|
+
railties (= 3.0.1)
|
66
|
+
railties (3.0.1)
|
67
|
+
actionpack (= 3.0.1)
|
68
|
+
activesupport (= 3.0.1)
|
69
|
+
rake (>= 0.8.4)
|
70
|
+
thor (~> 0.14.0)
|
71
|
+
rake (0.8.7)
|
72
|
+
rspec (2.1.0)
|
73
|
+
rspec-core (~> 2.1.0)
|
74
|
+
rspec-expectations (~> 2.1.0)
|
75
|
+
rspec-mocks (~> 2.1.0)
|
76
|
+
rspec-core (2.1.0)
|
77
|
+
rspec-expectations (2.1.0)
|
78
|
+
diff-lcs (~> 1.1.2)
|
79
|
+
rspec-mocks (2.1.0)
|
80
|
+
rspec-rails (2.1.0)
|
81
|
+
rspec (~> 2.1.0)
|
82
|
+
ruby-debug (0.10.4)
|
83
|
+
columnize (>= 0.1)
|
84
|
+
ruby-debug-base (~> 0.10.4.0)
|
85
|
+
ruby-debug-base (0.10.4)
|
86
|
+
linecache (>= 0.3)
|
87
|
+
sqlite3-ruby (1.3.2)
|
88
|
+
thor (0.14.4)
|
89
|
+
treetop (1.4.8)
|
90
|
+
polyglot (>= 0.3.1)
|
91
|
+
tzinfo (0.3.23)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
rails (>= 3)
|
98
|
+
render_with_missing_template!
|
99
|
+
rspec-rails
|
100
|
+
ruby-debug (>= 0.10.3)
|
101
|
+
sqlite3-ruby
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2010 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= render_with_missing_template
|
2
|
+
|
3
|
+
== Examples:
|
4
|
+
|
5
|
+
app/controllers/test_controller.rb
|
6
|
+
|
7
|
+
def index
|
8
|
+
# Renders template layouts/default/index if tests/index is missing
|
9
|
+
render :if_missing => {:template => "layouts/default/index"}
|
10
|
+
end
|
11
|
+
|
12
|
+
app/views/index.html.erb
|
13
|
+
|
14
|
+
<!-- Renders nothing if "navigation2" is missing -->
|
15
|
+
<%= render :partial => "navigation2", :if_missing => false %>
|
16
|
+
|
17
|
+
<!-- Renders template "layouts/defaults/navigation" if "navigation2" is missing -->
|
18
|
+
<%= render :partial => "navigation2", :if_missing => {:template => "layouts/defaults/navigation"} %>
|
19
|
+
|
20
|
+
== Note
|
21
|
+
|
22
|
+
app/controllers/test_controller.rb
|
23
|
+
|
24
|
+
def index
|
25
|
+
# Renders template layouts/default/index if tests/index is missing
|
26
|
+
render :if_missing => {:template => "layouts/default/index"}
|
27
|
+
end
|
28
|
+
|
29
|
+
app/views/index.html.erb
|
30
|
+
|
31
|
+
<!-- Raises TemplateMissing because there is no :if_missing option here. -->
|
32
|
+
<%= render :partial => "navigation2" %>
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rake'
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
task :default => :spec
|
8
|
+
|
9
|
+
begin
|
10
|
+
require "jeweler"
|
11
|
+
Jeweler::Tasks.new do |gem|
|
12
|
+
gem.name = "render_with_missing_template"
|
13
|
+
gem.summary = "Extends rails render method to accept default template when expected template is missing"
|
14
|
+
gem.description = "Extends rails render method to render default template when expected template is missing"
|
15
|
+
gem.files = FileList["[A-Z]*", "lib/**/*"]
|
16
|
+
gem.version = "0.0.3"
|
17
|
+
gem.email = "gzigzigzeo@gmail.com"
|
18
|
+
gem.authors = ["Victor Sokolov"]
|
19
|
+
gem.homepage = "http://github.com/gzigzigzeo/render_with_missing_template"
|
20
|
+
|
21
|
+
gem.add_dependency "rails", ">= 3.0.0"
|
22
|
+
end
|
23
|
+
|
24
|
+
Jeweler::GemcutterTasks.new
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
27
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
module RenderWithMissingTemplate
|
2
|
+
require 'render_with_missing_template/missing_template_container'
|
3
|
+
require 'render_with_missing_template/action_controller'
|
4
|
+
require 'render_with_missing_template/action_view'
|
5
|
+
require 'render_with_missing_template/railtie' if defined?(Rails)
|
6
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RenderWithMissingTemplate
|
2
|
+
module ActionController
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
alias_method_chain :render, :defaults
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
# ActionController::render overload is needed because ActionController::render have different
|
11
|
+
# signature and accepts different options.
|
12
|
+
def render_with_defaults(*args)
|
13
|
+
options = args.extract_options!
|
14
|
+
defaults = options.delete(:if_missing)
|
15
|
+
unless defaults.nil?
|
16
|
+
begin
|
17
|
+
# Ac is important:
|
18
|
+
# index/index.html.erb
|
19
|
+
# render "missing_partial" # MissingTemplate is raised here
|
20
|
+
#
|
21
|
+
# index_controller.rb
|
22
|
+
# def index
|
23
|
+
# render :if_missing => {:template => "layouts/create_me"} # And caught here
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# In fact MissingTemplate in a view should not be caught by controller because controller's template exists, but
|
27
|
+
# it have errors inside. :nested option tells nested render to raise MissingTemplateContrainer exception instead of
|
28
|
+
# raising MissingTemplate. This exception means that action template is resolved, but some of nested partials are not.
|
29
|
+
render_without_defaults(options.merge(:nested => true))
|
30
|
+
rescue MissingTemplateContainer => e
|
31
|
+
unless defaults == false
|
32
|
+
render_without_defaults(defaults)
|
33
|
+
else
|
34
|
+
render_without_defaults(:nothing => true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
render_without_defaults options
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module RenderWithMissingTemplate
|
2
|
+
module ActionView
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
alias_method_chain :render, :defaults
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
RENDER_KEYS = [:partial, :text, :template, :file, :inline]
|
11
|
+
|
12
|
+
def render_with_defaults(options = {}, locals = {}, &block)
|
13
|
+
if options.is_a?(Hash)
|
14
|
+
defaults = options.delete(:if_missing)
|
15
|
+
nested = options.delete(:nested)
|
16
|
+
elsif locals.is_a?(Hash)
|
17
|
+
defaults = locals.delete(:if_missing)
|
18
|
+
nested = locals.delete(:nested)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Prevents replacing :if_missing => false with empty hash.
|
22
|
+
unless defaults.nil?
|
23
|
+
begin
|
24
|
+
render_without_defaults(options, locals, &block)
|
25
|
+
rescue ::ActionView::MissingTemplate
|
26
|
+
unless defaults == false
|
27
|
+
defaults ||= {}
|
28
|
+
new_options = defaults
|
29
|
+
if options.is_a?(Hash)
|
30
|
+
new_options = defaults.reverse_merge(options)
|
31
|
+
|
32
|
+
# If user does something like
|
33
|
+
# render :partial => "test", :locals => {:temp => 1}, :if_missing => {:template => "missing"}
|
34
|
+
# We should replace :partial => "test" with :template => "missing" and keep :locals.
|
35
|
+
|
36
|
+
# Determine that render options have two template reference keys.
|
37
|
+
render_keys = RENDER_KEYS.map { |k| k if new_options.include?(k) }.compact
|
38
|
+
if render_keys.size > 1
|
39
|
+
# And delete unneccessary keys from default options.
|
40
|
+
new_options = new_options.delete_if { |k, v| render_keys.include?(k) && options.include?(k) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
render_without_defaults(new_options, locals, &block)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
else
|
47
|
+
begin
|
48
|
+
render_without_defaults(options, locals, &block)
|
49
|
+
rescue ::ActionView::MissingTemplate => e
|
50
|
+
if nested
|
51
|
+
raise MissingTemplateContainer.new(e)
|
52
|
+
else
|
53
|
+
raise e
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RenderWithMissingTemplate
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
initializer "render_with_missing_template.on_controller" do |app|
|
4
|
+
ActiveSupport.on_load :action_controller do
|
5
|
+
::ActionController::Base.send(:include, RenderWithMissingTemplate::ActionController)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer "render_with_missing_template.on_view" do |app|
|
10
|
+
ActiveSupport.on_load :action_view do
|
11
|
+
::ActionView::Base.send(:include, RenderWithMissingTemplate::ActionView)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApplicationController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
it "should render show action if index template missing" do
|
7
|
+
get :regular_missing
|
8
|
+
response.should render_template("show")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not render index action if show template exists" do
|
12
|
+
get :not_missing
|
13
|
+
response.should render_template("show")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not raise exception if :default => false" do
|
17
|
+
proc { get :suspend_missing_error }.should_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise an error if both default & if_missing templates are not found" do
|
21
|
+
proc { get :all_missing }.should raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an error if controller template found && partial not found" do
|
25
|
+
lambda { get :error_in_regular }.should raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
it "should raise error if it raises in nested template" do
|
30
|
+
lambda { get :nested }.should raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should raise error if it raises in nested missing template" do
|
34
|
+
lambda { get :all_missing, :if_missing => {:action => :nested} }.should raise_error
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
protect_from_forgery
|
3
|
+
|
4
|
+
def regular_missing
|
5
|
+
render :if_missing => {:action => :show}
|
6
|
+
end
|
7
|
+
|
8
|
+
def not_missing
|
9
|
+
render :action => "show", :if_missing => {:action => :index}
|
10
|
+
end
|
11
|
+
|
12
|
+
def suspend_missing_error
|
13
|
+
render :if_missing => false
|
14
|
+
end
|
15
|
+
|
16
|
+
def all_missing
|
17
|
+
render :partial => "nano", :if_missing => {:template => "notfound"}
|
18
|
+
end
|
19
|
+
|
20
|
+
def error_in_regular
|
21
|
+
render :if_missing => {:template => "notfound"}
|
22
|
+
end
|
23
|
+
|
24
|
+
def nested
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
|
11
|
+
module Dummy
|
12
|
+
class Application < Rails::Application
|
13
|
+
# Settings in config/environments/* take precedence over those specified here.
|
14
|
+
# Application configuration should go into files in config/initializers
|
15
|
+
# -- all .rb files in that directory are automatically loaded.
|
16
|
+
|
17
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
18
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
19
|
+
|
20
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
21
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
22
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
23
|
+
|
24
|
+
# Activate observers that should always be running.
|
25
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
26
|
+
|
27
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
28
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
29
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
30
|
+
|
31
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
32
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
33
|
+
# config.i18n.default_locale = :de
|
34
|
+
|
35
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
36
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
37
|
+
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
39
|
+
config.encoding = "utf-8"
|
40
|
+
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
42
|
+
config.filter_parameters += [:password]
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
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.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies 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
|
+
Dummy::Application.config.secret_token = '811de66db7d89979e5bc3418c1f9831e2eb750ca7dff2ef4ccec144fc41b36195b7e7e21d67347d479b7e177cc6d64287f9e914cfe9dfd39400376473eae0f78'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rake db:sessions:create")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
require "rspec/rails"
|
7
|
+
|
8
|
+
ActionMailer::Base.delivery_method = :test
|
9
|
+
ActionMailer::Base.perform_deliveries = true
|
10
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
11
|
+
|
12
|
+
Rails.backtrace_cleaner.remove_silencers!
|
13
|
+
|
14
|
+
# Run any available migration
|
15
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
16
|
+
|
17
|
+
# Load support files
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# Remove this line if you don't want Rspec's should and should_not
|
22
|
+
# methods or matchers
|
23
|
+
require 'rspec/expectations'
|
24
|
+
config.include Rspec::Matchers
|
25
|
+
|
26
|
+
# == Mock Framework
|
27
|
+
config.mock_with :rspec
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: render_with_missing_template
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Victor Sokolov
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-08 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rails
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 3.0.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Extends rails render method to render default template when expected template is missing
|
38
|
+
email: gzigzigzeo@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README.rdoc
|
45
|
+
files:
|
46
|
+
- Gemfile
|
47
|
+
- Gemfile.lock
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- lib/render_with_missing_template.rb
|
52
|
+
- lib/render_with_missing_template/action_controller.rb
|
53
|
+
- lib/render_with_missing_template/action_view.rb
|
54
|
+
- lib/render_with_missing_template/missing_template_container.rb
|
55
|
+
- lib/render_with_missing_template/railtie.rb
|
56
|
+
- spec/controllers/render_with_missing_template_spec.rb
|
57
|
+
- spec/dummy/app/controllers/application_controller.rb
|
58
|
+
- spec/dummy/app/helpers/application_helper.rb
|
59
|
+
- spec/dummy/config/application.rb
|
60
|
+
- spec/dummy/config/boot.rb
|
61
|
+
- spec/dummy/config/environment.rb
|
62
|
+
- spec/dummy/config/environments/development.rb
|
63
|
+
- spec/dummy/config/environments/production.rb
|
64
|
+
- spec/dummy/config/environments/test.rb
|
65
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
66
|
+
- spec/dummy/config/initializers/inflections.rb
|
67
|
+
- spec/dummy/config/initializers/mime_types.rb
|
68
|
+
- spec/dummy/config/initializers/secret_token.rb
|
69
|
+
- spec/dummy/config/initializers/session_store.rb
|
70
|
+
- spec/dummy/config/routes.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- spec/views/application/test.html.erb_spec.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/gzigzigzeo/render_with_missing_template
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.3.7
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Extends rails render method to accept default template when expected template is missing
|
107
|
+
test_files:
|
108
|
+
- spec/controllers/render_with_missing_template_spec.rb
|
109
|
+
- spec/dummy/app/controllers/application_controller.rb
|
110
|
+
- spec/dummy/app/helpers/application_helper.rb
|
111
|
+
- spec/dummy/config/application.rb
|
112
|
+
- spec/dummy/config/boot.rb
|
113
|
+
- spec/dummy/config/environment.rb
|
114
|
+
- spec/dummy/config/environments/development.rb
|
115
|
+
- spec/dummy/config/environments/production.rb
|
116
|
+
- spec/dummy/config/environments/test.rb
|
117
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
118
|
+
- spec/dummy/config/initializers/inflections.rb
|
119
|
+
- spec/dummy/config/initializers/mime_types.rb
|
120
|
+
- spec/dummy/config/initializers/secret_token.rb
|
121
|
+
- spec/dummy/config/initializers/session_store.rb
|
122
|
+
- spec/dummy/config/routes.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
- spec/views/application/test.html.erb_spec.rb
|