ruby on rails - Show Results Based on experiment_type -


i have table experiments in database populated filling out form. 1 of fields in form experiment_type, drop down option select between either aov or conversion. in show.html.erb i'd display aov experiments , conversion experiments seperately. i'm kinda stuck on begin this. thought in show action like

@aov_experiment = experiment.where(:experiment_type => "aov").order("created_at desc")  @conversion_experiment = experiment.where(:experiment_type => "conversion").order("created_at desc") 

then loop through , show results in show.html.erb

i think way off here. hoping can point me in right direction.

source code displaying tabs

  <!-- start aov experiments -->                                              <table class="data table table-striped no-margin">                           <thead>                             <tr>                               <th>id</th>                               <th>experiment name</th>                               <th>status</th>                               <th>priority</th>                               <th>launch date</th>                             </tr>                           </thead>                           <% @advertiser.experiments.each |experiments| %>                           <tbody>                             <tr>                                <td><%= @advertiser.experiments %></td>                               <td></td>                               <td></td>                               <td></td>                               <td></td>                              </tr>                                                          </tbody>                         <% end %>                         </table>    <!-- end aov experiments -->                        </div>                       <div></div>                       <div role="tabpanel" class="tab-pane fade" id="tab_content2" aria-labelledby="profile-tab">      <!-- start conversion experiments -->                           <table class="data table table-striped no-margin">                           <thead>                             <tr>                               <th>id</th>                               <th>experiment name</th>                               <th>status</th>                               <th>priority</th>                               <th>launch date</th>                             </tr>                           </thead>                           <!-- begin iteration here -->                           <tbody>                             <tr>                                <td></td>                               <td></td>                               <td></td>                               <td></td>                               <td></td>                              </tr>                                                          </tbody>                         <!-- end iteration here -->                         </table>                 <!-- end conversion experiments -->                        </div> 

rather hard coding in active record query, can use below,

experiment.all.collect(&:experiment_type).uniq => ["aov", "conversion",.....] 

you can iterate items above array display tab values. can use ajax load content of tabs. if find difficulty ask me...i tell how that....

but guess give enough idea.

happy coding!!!!!


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -