Skip to content

Instantly share code, notes, and snippets.

@noltedesign
Created October 16, 2015 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noltedesign/42995606b94a0b4780a8 to your computer and use it in GitHub Desktop.
Save noltedesign/42995606b94a0b4780a8 to your computer and use it in GitHub Desktop.
class EventsController < ApplicationController
before_filter :authenticate_user!
def index
end
def show
@event = Event.find_by_id(params[:id])
end
def new
@event = Event.new
end
def create
@event = Event.new(event_params)
if @event.save
flash[:success] = "Event Created"
redirect_to @event
@event_instance = EventInstance.new(:event_id => @event.id)
@event_instance.save
else
render 'new'
end
end
private
def event_params
params[:event][:owner_id] = current_user.id
params.require(:event).permit(:owner_id, :name, :description, :image, :street_address, :city, :state_province, :zip, :repeat_event, :repeat_interval, :repeat_holidays, :event_end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment