diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-05-14 17:30:35 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-05-14 17:30:35 +0000 |
commit | 6e7b593992f8f6f8e783b87e7ab9d1d5a97063f7 (patch) | |
tree | 8de722a5e02bd4e0e7bcfc10bc3a677d1744b9f4 /actionpack/lib/action_controller | |
parent | 50253edec97429ea92621bce6578cdedfcc19b62 (diff) | |
download | rails-6e7b593992f8f6f8e783b87e7ab9d1d5a97063f7.tar.gz rails-6e7b593992f8f6f8e783b87e7ab9d1d5a97063f7.tar.bz2 rails-6e7b593992f8f6f8e783b87e7ab9d1d5a97063f7.zip |
Added record identifications to FormHelper#form_for and PrototypeHelper#remote_form_for [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6731 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/polymorphic_routes.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_controller/record_identifier.rb | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index a9d502e6f1..c922dc7284 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -999,6 +999,7 @@ module ActionController #:nodoc: # Redirects the browser to the target specified in +options+. This parameter can take one of three forms: # # * <tt>Hash</tt>: The URL will be generated by calling url_for with the +options+. + # * <tt>Record</tt>: The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record. # * <tt>String starting with protocol:// (like http://)</tt>: Is passed straight through as the target for redirection. # * <tt>String not containing a protocol</tt>: The current protocol and host is prepended to the string. # * <tt>:back</tt>: Back to the page that issued the request. Useful for forms that are triggered from multiple places. @@ -1006,6 +1007,7 @@ module ActionController #:nodoc: # # Examples: # redirect_to :action => "show", :id => 5 + # redirect_to post # redirect_to "http://www.rubyonrails.org" # redirect_to "/images/screenshot.jpg" # redirect_to :back diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb index eeddc28d60..88bd7ab192 100644 --- a/actionpack/lib/action_controller/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/polymorphic_routes.rb @@ -7,10 +7,14 @@ module ActionController case when options[:action] == "new" - url_writer.send(action_prefix(options) + RecordIdentifier.singular_class_name(record) + routing_type(options)) + url_writer.send( + action_prefix(options) + RecordIdentifier.singular_class_name(record) + routing_type(options) + ) when record.respond_to?(:new_record?) && record.new_record? - url_writer.send(RecordIdentifier.plural_class_name(record) + routing_type(options)) + url_writer.send( + action_prefix(options) + RecordIdentifier.plural_class_name(record) + routing_type(options) + ) else url_writer.send( diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index 1247665a8b..1a60becff3 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -63,7 +63,7 @@ module ActionController # # dom_class(Post.new(:id => 45), :edit) # => "edit_post_45" def dom_id(record, prefix = nil) - prefix ||= 'new' unless record.id + prefix ||= 'new' unless record.id [ prefix, singular_class_name(record), record.id ].compact * '_' end |