{"id":782,"date":"2022-08-30T15:07:05","date_gmt":"2022-08-30T15:07:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/how-to-use-form_for-helper-in-rails-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:05","modified_gmt":"2022-08-30T15:07:05","slug":"how-to-use-form_for-helper-in-rails-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-use-form_for-helper-in-rails-collection-of-common-programming-errors\/","title":{"rendered":"How to use form_for helper in rails?-Collection of common programming errors"},"content":{"rendered":"<p>New to rails. I am using form_for helper in rails 2.3.5. The question is, when editing a record, I cannot use:<\/p>\n<blockquote>\n<p><code>{:action =&gt; :update} %&gt;<\/code> <code>...<\/code><\/p>\n<\/blockquote>\n<p>But I have to use:<\/p>\n<blockquote>\n<p><code>{:action =&gt; :update} %&gt;<\/code> <code>... # the same as above<\/code><\/p>\n<\/blockquote>\n<p>When I use the first code, it always return error saying undefined method. Shouldn&#8217;t the first code and the second code serves the same when &#8220;myrecord&#8221; is the name of the instance passed from controller to view?<\/p>\n<p>Thank you for any hints and answers.<\/p>\n<ol>\n<li>\n<p>form_for take a block so it&#8217;s more like. If this record is same that resource, the :url option is not needed. FormHelper check if @myrecord is #new_record? or not. If new_record use POST instead use PUT.<\/p>\n<pre><code>\n \n  \n\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:43:59. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>New to rails. I am using form_for helper in rails 2.3.5. The question is, when editing a record, I cannot use: {:action =&gt; :update} %&gt; &#8230; But I have to use: {:action =&gt; :update} %&gt; &#8230; # the same as above When I use the first code, it always return error saying undefined method. Shouldn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-782","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=782"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/782\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}