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 -- Posted via http://www.ruby-forum.com/.
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 <bduenskie@gmail.com> wrote:> 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com
Ben Reubenstein 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 <bduenskie@gmail.com> wrote: >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Ben Reubenstein > http://www.benr75.comThanks Ben, it helps a lot. Bill -- Posted via http://www.ruby-forum.com/.