# REST and remote\_form\_for

**URL:** <https://www.ruby-forum.com/t/rest-and-remote-form-for/141942>\
**Category:** Rails\
**Created:** [July 1, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/rest-and-remote-form-for/141942 "2008-07-01T23:15:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [July 1, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/rest-and-remote-form-for/141942/1 "2008-07-01T23:15:01Z")

</div>

Hi,

I don’t see where i’m wrong, it’s probably terribly stupid, but i don’t  
get the point…

I’m investigating the resources mapping, but the path mapping doesn’t  
seem to work :

in my config directory  
map.resources :clients

class ClientsController \< ApplicationController  
def create  
@client = Client.create(params[:client])  
end  
end

in my view :

\<% remote\_form\_for @client do |f| %\>  
(…)  
\<%= submit\_tag ‘OK’ , :id =\> “submit\_form\_client” %\>  
\<% end %\>

The html generated is :

> > > > controller keeps hitting the index action, whatever i try.

---

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [July 2, 2008, 12:00am UTC](https://www.ruby-forum.com/t/rest-and-remote-form-for/141942/2 "2008-07-02T00:00:51Z")

</div>

I am new to RoR, but don’t you have to explicitly specify the action  
of your form? The Ajax code above seems to have the index as action.

So, I have tried something like:

\<% remote\_form\_for @client, :url =\> { :action =\> ‘some method in your  
controller’ :id → @client} do |f| %\>

Amrita

On Jul 1, 2:15 pm, nico Itkin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [July 2, 2008, 12:34am UTC](https://www.ruby-forum.com/t/rest-and-remote-form-for/141942/3 "2008-07-02T00:34:37Z")

</div>

amrita wrote:

> I am new to RoR, but don’t you have to explicitly specify the action  
> of your form? The Ajax code above seems to have the index as action.
> 
> So, I have tried something like:
> 
> \<% remote\_form\_for @client, :url =\> { :action =\> ‘some method in your  
> controller’ :id → @client} do |f| %\>
> 
> Amrita
> 
> On Jul 1, 2:15 pm, nico Itkin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

new to rails too…

apparently i don’t need to write the action name in the view thanks to  
the path mapping defined in route.rb, rails find from the route and the  
method of the query.

but apparently it’s not working … and i don’t know why …

---

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [July 3, 2008, 8:54pm UTC](https://www.ruby-forum.com/t/rest-and-remote-form-for/141942/4 "2008-07-03T20:54:12Z")

</div>

nico Itkin wrote:

> amrita wrote:
> 
> > I am new to RoR, but don’t you have to explicitly specify the action  
> > of your form? The Ajax code above seems to have the index as action.
> > 
> > So, I have tried something like:
> > 
> > \<% remote\_form\_for @client, :url =\> { :action =\> ‘some method in your  
> > controller’ :id → @client} do |f| %\>
> > 
> > Amrita
> > 
> > On Jul 1, 2:15 pm, nico Itkin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> new to rails too…
> 
> apparently i don’t need to write the action name in the view thanks to  
> the path mapping defined in route.rb, rails find from the route and the  
> method of the query.
> 
> but apparently it’s not working … and i don’t know why …

the problem came from the file routes.rb, the default mapping routes  
have to be placed at in last position… works perfectly now !!

itkin
