Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Forked from pluralism/RegistrationController.rb
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbuehlmann/9725584 to your computer and use it in GitHub Desktop.
Save tbuehlmann/9725584 to your computer and use it in GitHub Desktop.
class RegistrationsController < ApplicationController
before_filter :authenticate_athlete!, :only => [:new, :create]
def new
@race = Race.find(params[:race_id])
@registration = @race.registrations.new
end
def create
@race = Race.find(params[:race_id])
@registration = @race.registrations.new(registration_params)
if @registration.save
redirect_to @race, notice: 'Athlete registered.'
else
render 'new'
end
end
private
def registration_params
params.require(:registration).permit(:athlete_id, :athlete_team)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment