Form Posts Across Different Controllers?


#1

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


#2

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

http://lun.competo.com