Calling an action in another controller

I have two controllers, one for lists and one for list items. When I’m
viewing a list I’d like to have a link to create list items within that
list. How do I go about calling an action in the listitems controller
to create a new item within that specific list?

Thanks

Hi Bill ~

I think your design might be flawed here. You probably want one list
controller with several actions. Maybe a list action to show all the
items and a list_add action to add an item. You can link to another
controller, but it is not very DRY.

If you really want to link to the action in the other controller, you
can do:

<%= link_to(“New list Item”, :controller => “listitem”, :action =>
“ACTION YOU WANT TO CALL HERE”) %>

If they were in the same controller, you can just do:

<%= link_to(“New list Item”, :action => “ACTION YOU WANT TO CALL HERE”)
%>

Hope this helps,

~ Ben

On 3/25/06, Bill [email protected] wrote:

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Ben R.
http://www.benr75.com

Ben R. wrote:

Hi Bill ~

I think your design might be flawed here. You probably want one list
controller with several actions. Maybe a list action to show all the
items and a list_add action to add an item. You can link to another
controller, but it is not very DRY.

If you really want to link to the action in the other controller, you
can do:

<%= link_to(“New list Item”, :controller => “listitem”, :action =>
“ACTION YOU WANT TO CALL HERE”) %>

If they were in the same controller, you can just do:

<%= link_to(“New list Item”, :action => “ACTION YOU WANT TO CALL HERE”)
%>

Hope this helps,

~ Ben

On 3/25/06, Bill [email protected] wrote:

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Ben R.
http://www.benr75.com

Thanks Ben, it helps a lot.

Bill

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs