aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/callbacks.rb21
-rw-r--r--railties/guides/rails_guides/generator.rb6
-rw-r--r--railties/guides/source/_welcome.html.erb14
3 files changed, 20 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 11069301f1..ba9fb4ecce 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -378,18 +378,15 @@ module ActiveSupport
module ClassMethods
# Generate the internal runner method called by +run_callbacks+.
def __define_runner(symbol) #:nodoc:
- body = send("_#{symbol}_callbacks").compile
- runner_method = "_run_#{symbol}_callbacks"
+ name = __callback_runner_name(nil, symbol)
+ undef_method(name) if method_defined?(name)
silence_warnings do
+ runner_method = "_run_#{symbol}_callbacks"
undef_method runner_method if method_defined?(runner_method)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{runner_method}(key = nil, &blk)
- if key
- self.class.__run_keyed_callback(key, :#{symbol}, self, &blk)
- else
- #{body}
- end
+ self.class.__run_callback(key, :#{symbol}, self, &blk)
end
private :#{runner_method}
RUBY_EVAL
@@ -400,10 +397,10 @@ module ActiveSupport
# If this called first time it creates a new callback method for the key,
# calculating which callbacks can be omitted because of per_key conditions.
#
- def __run_keyed_callback(key, kind, object, &blk) #:nodoc:
- name = "_run__#{self.name.hash.abs}__#{kind}__#{key.hash.abs}__callbacks"
+ def __run_callback(key, kind, object, &blk) #:nodoc:
+ name = __callback_runner_name(key, kind)
unless object.respond_to?(name)
- str = send("_#{kind}_callbacks").compile(name, object)
+ str = send("_#{kind}_callbacks").compile(key, object)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{name}() #{str} end
protected :#{name}
@@ -412,6 +409,10 @@ module ActiveSupport
object.send(name, &blk)
end
+ def __callback_runner_name(key, kind)
+ "_run__#{self.name.hash.abs}__#{kind}__#{key.hash.abs}__callbacks"
+ end
+
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
#
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb
index b5f1a471ef..49ad8f7769 100644
--- a/railties/guides/rails_guides/generator.rb
+++ b/railties/guides/rails_guides/generator.rb
@@ -49,8 +49,8 @@
#
# KINDLE
# Set to "1" to generate the .mobi with all the guides. The kindlegen
-# executable must be in your PATH. Google for it if you do not have it
-# locally, it is available from Amazon for free.
+# executable must be in your PATH. You can get it for free from
+# http://www.amazon.com/kindlepublishing
#
# ---------------------------------------------------------------------------
@@ -199,7 +199,7 @@ module RailsGuides
layout = kindle? ? 'kindle/layout' : 'layout'
File.open(output_path, 'w') do |f|
- view = ActionView::Base.new(source_dir, :version => @version, :mobi => "kindle/#{mobi}")
+ view = ActionView::Base.new(source_dir, :edge => @edge, :version => @version, :mobi => "kindle/#{mobi}")
view.extend(Helpers)
if guide =~ /\.(\w+)\.erb$/
diff --git a/railties/guides/source/_welcome.html.erb b/railties/guides/source/_welcome.html.erb
index a5ceeee5f2..e5373ebca0 100644
--- a/railties/guides/source/_welcome.html.erb
+++ b/railties/guides/source/_welcome.html.erb
@@ -1,21 +1,19 @@
-<h2>Ruby on Rails Guides (<%= @version %>)</h2>
+<h2>Ruby on Rails Guides</h2>
<% if @edge %>
<p>
- These are <b>Edge Guides</b>, based on the current
- <a href="https://github.com/rails/rails/tree/master">master branch</a>.
+ These are <b>Edge Guides</b>, based on the current <a href="https://github.com/rails/rails/tree/<%= @version %>">master</a> branch.
</p>
<p>
- If you are looking for the ones for the stable version please check
+ If you are looking for the ones for the stable version, please check
<a href="http://guides.rubyonrails.org">http://guides.rubyonrails.org</a> instead.
</p>
<% else %>
<p>
- These are the new guides for Rails 3. The guides for Rails 2.3 are still available
- at <a href="http://guides.rubyonrails.org/v2.3.11/">http://guides.rubyonrails.org/v2.3.11/</a>.
+ These are the new guides for Rails 3.1 based on <a href="https://github.com/rails/rails/tree/<%= @version %>"><%= @version %></a>.
+ These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together.
</p>
<% end %>
<p>
- These guides are designed to make you immediately productive with Rails,
- and to help you understand how all of the pieces fit together.
+ The guides for Rails 2.3.x are available at <a href="http://guides.rubyonrails.org/v2.3.11/">http://guides.rubyonrails.org/v2.3.11/</a>.
</p>