# Form Posts Across Different Controllers?

**URL:** <https://www.ruby-forum.com/t/form-posts-across-different-controllers/156980>\
**Category:** Rails\
**Created:** [January 6, 2009, 1:29am UTC](https://www.ruby-forum.com/t/form-posts-across-different-controllers/156980 "2009-01-06T01:29:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/90ced4/32.png) [@davox](https://www.ruby-forum.com/u/davox)\
**Post date:** [January 6, 2009, 1:29am UTC](https://www.ruby-forum.com/t/form-posts-across-different-controllers/156980/1 "2009-01-06T01:29:30Z")

</div>

I have a basic, basic question about form posting across different  
controllers. I think I’m having a fundamental problem understanding html  
forms, while ruby I understand fairly well.

If I have on my “item” “show” page:

\<% form\_tag ‘/users’ do %\>  
\<%= hidden\_field\_tag “id”, @item.id %\>  
\<%= submit\_tag “Add Item” %\>  
\<% end %\>

and in my “users” “show” controller I have:

def show  
flash[:notice] = params  
end

I just want some sign that my items controller has passed an id in the  
hash to the users controller. For some reason this does not work and  
only “actionshowcontrollerusers” shows up in the hash. If I could just  
get the item ID from the items controller, I’d be set, but for some  
reason I’m not able to transfer data between controllers…

PLEASE help. Thank you.

David

---

<div class="post-metadata">

**Author:** ![davox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/90ced4/32.png) [@davox](https://www.ruby-forum.com/u/davox)\
**Post date:** [January 6, 2009, 3:36am UTC](https://www.ruby-forum.com/t/form-posts-across-different-controllers/156980/2 "2009-01-06T03:36:19Z")

</div>

David D. wrote:

> I have a basic, basic question about form posting across different  
> controllers. I think I’m having a fundamental problem understanding html  
> forms, while ruby I understand fairly well.
> 
> If I have on my “item” “show” page:
> 
> \<% form\_tag ‘/users’ do %\>  
> \<%= hidden\_field\_tag “id”, @item.id %\>  
> \<%= submit\_tag “Add Item” %\>  
> \<% end %\>
> 
> and in my “users” “show” controller I have:
> 
> def show  
> flash[:notice] = params  
> end
> 
> I just want some sign that my items controller has passed an id in the  
> hash to the users controller. For some reason this does not work and  
> only “actionshowcontrollerusers” shows up in the hash. If I could just  
> get the item ID from the items controller, I’d be set, but for some  
> reason I’m not able to transfer data between controllers…
> 
> PLEASE help. Thank you.
> 
> David

Not sure fullyy understanding your problem, but if you’re not using  
resource based approach, you need to define specifc routes in your  
config/routes.rb to hook up the url used in your form and how it’s  
routed to a controller’s method.

Usually any errors/message shown in the debug or script/server console  
messages should help you see the request url posted by your form and if  
it’s understood by the routes.

Regards,

# rp8

> **[Competo Solutions, Inc.](https://competo.com/)**
>
> Sharing our experience in ever changing tech landscapes
