Is there a way to list (index) a table from a different unrelated view?
I have a Calendar view for using jquery Fullcalendar and an Events table. The Calendar doesn’t have a model, so I can’t relate it to Events.
Using the same code from the Events/index doesn’t work:
<% @events.each do |event| %>
or
<% Events.each do |event| %>
I get:
You have a nil object when you didn't expect it!
In any view you can show anything you want from any of your database tables, you simply need to pass it to the correct action in the controller.
So in whatever controller/action is displaying the Calendar view, add a
@events = Event.all(or narrow the search as you like). Then this instance variable becomes accessible in the views, and you can call it like you did: