I have an admin controller that is just used for its index action which renders a view with the most recent updates to certain resources:
class AdminController < ApplicationController before_action :authenticate_user! layout "admin" def index @events = Event.last(3) @foos = Foo.last(3) @bars = Bar.last(3) end end
Now, I want to create a new event. So I have an Events controller:
class EventsController < ApplicationController before_action :authenticate_user!, only: [:new,:create] layout "admin", only: [:new] def index @events = Event.all end def show end def new end def create end end
But I want to display a list of events that have previously been added in the same view as the form for creating a new event. Should I retrieve all the events in the new action? i.e.
def new @events = Event.all end
Or is there a better approach(perhaps more restful)?