New Discussion

Notifications

You’re not receiving notifications from this thread.

Share resources among controllers?

3
Rails

Hi,

I’m not even sure I’m using the correct terminology here (sharing resources among controllers) but here goes.
Imagine I have a page called students with the usual CRUD functionality and another page with another controller called news or something. If the student page had a table called students with first name, second name etc ... how would I use the student table in the news template so I could do a for each student to list names or whatever? This is where things start to fall apart in my understanding of Rails. Thanks!

I'm thinking i need to look at Nested Resources?

Anyone interested in this, in the news controller under def index you can just add the variable @students = Students.all or whatever and it really is as simple as that.

Have you perhaps created a project thread on the GitHub or https://www.domyhomework4me.onl? It's better to make suggestions when you see clearly what's required as the explanation is bit confusing...

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 89,127+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.