简体   繁体   中英

How to call multiple controller actions into the single page tabs in ruby on rails

I have three models, controllers and views .

1. package
2. source
3. measure

Everything has separate forms . I created a controller and view called scenario and created three tabs(Package, Source and Measure) in the scenario page.

I need to render the three tabs to call each one of the above controller and views like Package should do the action of create, edit, update and destroy of Packages controller and vice-verse.

How should i call those three different controller actions in the Scenario page? I want all the three into the single page and work within their tabs .

What shall i include in the index, new, create, edit and update methods in Scenario controller? Do i need to create all the view files for scenario too?

Any help would be more appreciated.

PS I tested all the three are working fine with their separate pages.

best to use ajax calls and render the view templates within the respective tab with js/erb template. eg,

show.js.erb

$('<%= @selector %>').html("<%= escape_javascript(render(:action => :show)) %>");

if you wanna use this same ajax call to render show action elsewhere, then send a selector as a request param depending on which page you are on: eg, when you are on the scenario page and the div id for package tab is say 'package-tab', then send selector '#package-tab' as param and set @selector to this in your controller. with this you can control from the request which dom-element is refreshed by the ajax call.

does this answer the question?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM