# How to use form\_tag with a model?

**URL:** <https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369>\
**Category:** Rails\
**Created:** [August 16, 2010, 7:17pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369 "2010-08-16T19:17:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 16, 2010, 7:17pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369/1 "2010-08-16T19:17:59Z")

</div>

Editing records of my model requires an intermediate layer of software,  
so I cannot use form\_for for data aqusition.

My edit action calls the form. But submitting the data always ends with  
a “Unknown action” response:

No action responded to 6. Actions: create, destroy, edit, index, new,  
show,  
and update

6 is the id of the record to be edited.  
The URL is [http://localhost:3000/finders/6](http://localhost:3000/finders/6)

Here are the relevant snippets of code:

controller:  
def edit  
@finder = Finder.find(params[:id]) # a record of the model  
end

view:  
\<% form\_tag(:action =\> ‘update’, :id =\> @finder.id ) do %\>  
\<%= submit\_tag ‘store’ %\>  
\<% end %\>

routes.rb:  
ActionController::Routing::Routes.draw do |map|  
map.resources :finders

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
end

Any idea, how to fix it?

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 16, 2010, 7:30pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369/2 "2010-08-16T19:30:26Z")

</div>

On Aug 16, 6:17 pm, Fritz T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Editing records of my model requires an intermediate layer of software,  
> so I cannot use form\_for for data aqusition.

I’m not sure that’s true (you don’t have to use the form builder for  
the actual inputs), but the core issue is probably that it’s expecting  
the update to be a PUT request.

Fred

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 16, 2010, 7:37pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369/3 "2010-08-16T19:37:47Z")

</div>

Frederick C. wrote:

> I’m not sure that’s true (you don’t have to use the form builder for  
> the actual inputs), but the core issue is probably that it’s expecting  
> the update to be a PUT request.

Adding a :method =\> ‘PUT’ doesn’t help.

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 16, 2010, 9:46pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369/4 "2010-08-16T21:46:17Z")

</div>

On 16 August 2010 18:37, Fritz T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Frederick C. wrote:
> 
> > I’m not sure that’s true (you don’t have to use the form builder for  
> > the actual inputs), but the core issue is probably that it’s expecting  
> > the update to be a PUT request.
> 
> Adding a :method =\> ‘PUT’ doesn’t help.

Should that be :put?

Colin

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 16, 2010, 10:01pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369/5 "2010-08-16T22:01:15Z")

</div>

Colin L. wrote:

> Should that be :put?

No, I tested all possible variants: nothing helps.  
\<% form\_tag(:action =\> “update”, :method =\> :put ) do %\>  
generates

and doesn't work.

When I manually enter the URL [http://localhost:3000/finders/6/update](http://localhost:3000/finders/6/update)  
then update gets called.

But how to force form\_tag to generate this action URL?

---

<div class="post-metadata">

**Author:** ![trapper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@trapper](https://www.ruby-forum.com/u/trapper)\
**Post date:** [August 16, 2010, 10:04pm UTC](https://www.ruby-forum.com/t/how-to-use-form-tag-with-a-model/193369/6 "2010-08-16T22:04:23Z")

</div>

Ok, I got it:

\<% form\_tag({ :action =\> “update” }, {:method =\> :put} ) do %\>

ends up in update.
