All threads / Share resources among controllers?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Share resources among controllers?

Tom Dringer asked in 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

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.