Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added that ActiveRecordHelper#form now calls url_for on the :action o…

…ption.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@62 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 3ee4357b8643c611bbe9eb3a7ce820a5e32cddaa 1 parent 63c4e78
@dhh dhh authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added that ActiveRecordHelper#form now calls url_for on the :action option.
+
* Added all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke]. Examples:
# Calls Controller#miletone with a GET request
View
2  actionpack/lib/action_controller/templates/scaffolds/edit.rhtml
@@ -1,6 +1,6 @@
<h1>Editing <%= @scaffold_singular_name %></h1>
-<%= form(@scaffold_singular_name, :action => "../update" + @scaffold_suffix) %>
+<%= form(@scaffold_singular_name, :action => "update" + @scaffold_suffix) %>
<%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}").id %> |
<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
View
6 actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -24,7 +24,7 @@ def input(record_name, method)
# Returns an entire form with input tags and everything for a specified Active Record object. Example
# (post is a new record that has a title using VARCHAR and a body using TEXT):
# form("post") =>
- # <form action='create' method='POST'>
+ # <form action='/post/create' method='POST'>
# <p>
# <label for="post_title">Title</label><br />
# <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
@@ -44,14 +44,14 @@ def input(record_name, method)
# form("entry", :action => "sign", :input_block =>
# Proc.new { |record, column| "#{column.human_name}: #{input(record, column.name)}<br />" }) =>
#
- # <form action='sign' method='POST'>
+ # <form action='/post/sign' method='POST'>
# Message:
# <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /><br />
# <input type='submit' value='Sign' />
# </form>
def form(record_name, options = {})
record = instance_eval("@#{record_name}")
- action = options[:action] || (record.new_record? ? "create" : "update")
+ action = url_for(:action => options[:action] || (record.new_record? ? "create" : "update"))
id_field = record.new_record? ? "" : InstanceTag.new(record_name, "id", self).to_input_field_tag("hidden")
"<form action='#{action}' method='POST'>" +
Please sign in to comment.
Something went wrong with that request. Please try again.