Added documentation for overwrite_params #2146 [Michael Shuerig]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2162 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 e3c02d8c
......@@ -425,6 +425,15 @@ def process(request, response, method = :perform_action, *arguments) #:nodoc:
#
# url_for :controller => 'posts', :action => nil
#
# If you explicitly want to create a URL that's almost the same as the current URL, you can do so using the
# :overwrite_params options. Say for your posts you have different views for showing and printing them.
# Then, in the show view, you get the URL for the print view like this
#
# url_for :overwrite_params => { :action => 'print' }
#
# This takes the current URL as is and only exchanges the action. In contrast, <tt>url_for :action => 'print'</tt>
# would have slashed-off the path components are the changed action.
#
# Instead of passing an options hash, you can also pass a method reference in the form of a symbol. Consider this example:
#
# class WeblogController < ActionController::Base
......
......@@ -134,8 +134,7 @@ def classify(table_name)
end
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
Inflector.underscore(Inflector.demodulize(class_name)) +
(separate_class_name_and_id_with_underscore ? "_id" : "id")
underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
end
def constantize(camel_cased_word)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册