Skip to content

Instantly share code, notes, and snippets.

@Sephi-Chan
Created March 1, 2012 23:19
Show Gist options
  • Save Sephi-Chan/1953958 to your computer and use it in GitHub Desktop.
Save Sephi-Chan/1953958 to your computer and use it in GitHub Desktop.
class UsersController < ApplicationController
rescue_from Location::NotAround, with: :handle_not_around_errors
def new
@user = User.new
end
def create
@user = User.new(params[:user])
@user.persistence_token = User.generate_persistence_token
@user.location = Location.find_available_location
if @user.save
cookies.permanent[:persistence_token] = @user.persistence_token
redirect_to root_path
else
render :new
end
end
def move
x = params[:x].to_i
y = params[:y].to_i
current_user.move(x, y)
redirect_to game_path
end
private
def handle_not_around_errors
do_somethind
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment