Take the 2-minute tour ×

I have 2 models = Generator and Results. Generator has_many : results and Result belongs_to:generator.

Views/generator/index and view/results/index have their own data. What i want to do is to have those 2 index page merge as 1. How should i do that ? Please show some examples if could. I'm new to RoR ...

share|improve this question
I think you want to show generators and their respective results on one page. In that case, you'll want to modify the generator view to include results using something like generator.results –  Akash Agrawal Jul 13 '13 at 18:58
yes that's what i want to do. How should i do it ? I did try generator.results.ncbi_ref_seq but the errors pops out saying undefined method results –  BC2 Jul 14 '13 at 13:03
what's ncbi_ref_seq? And is there some Generator object in generator or not. Why don't you use pastebin or gist to provide a few pieces of code. –  Akash Agrawal Jul 15 '13 at 7:45
add comment

1 Answer

I guess it is some kind of home page or dashboard for your app. For such cases I typically create a separate controller not to mess in my other RESTful ones.

To render two other views you may do

<%= render template: "generators/index" %>
<%= render template: "results/index" %>

Just remember to set all required variables (probably @generators & @results) in controller action

share|improve this answer
Hi michael , so i need 2 create a new controller ? because now i've got Genrator controller n Result controller . Lets say after i created the new controller , what should i do with that ? where should i place those 2 render templte code in ? and how should i call those collections. for example @generator.primer_length ( primer length is 1 of the attributes of generator) –  BC2 Jul 13 '13 at 18:34
I think you'll find all the answers here guides.rubyonrails.org –  Michael Szyndel Jul 13 '13 at 18:36
I mean - if you don't understand how to use my answer you REALLY should get and LEARN Rails not just try writing code with no understanding how it works. –  Michael Szyndel Jul 13 '13 at 18:37
add comment

Your Answer


