I have a relationship user ("devise") that has many events.

I want to prevent users from editing events that do not belong to them and stop users from accessing the edit action by entering something like `'http://localhost:3000/events/65/edit'` into the browser.

I also want to redirect the user back to the page they were on when clicking on the edit event link.

I tried the following two methods without success:

```
def edit
  if current_user == @event.user_id
    @event = Event.find(params[:id])
  else
    redirect_to events_path
  end

  def edit
    @event = Event.find(params[:id])
    unless session[:id] == @event.user_id
      redirect_to events_path
      return
    end
  end

```