Last active
May 13, 2018 14:24
-
-
Save CodePint/8e346ba2308759e3e773048200092028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@route = Route.new | |
@gym = Gym.find(params[:gym_id]) | |
end | |
def create | |
if current_user.route_setter | |
#binding.pry | |
@gym = Gym.find(params[:gym_id]) | |
@route = @gym.route.new(route_params) | |
if @route.save | |
puts "saved" | |
flash[:success]="New route #{@route.identifier} successfully added." | |
redirect_to '/' | |
end | |
else | |
flash[:error]="you do not have correct permmisions to do this, you are not a route setter" | |
puts "not saved" | |
render :new | |
end | |
end | |
def route_params | |
params.require(:route).permit(:identifier, :route_setter_comments, :grade) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment