Skip to content

Instantly share code, notes, and snippets.

@volgar1x
Created December 24, 2012 15:37
Show Gist options
  • Save volgar1x/4369673 to your computer and use it in GitHub Desktop.
Save volgar1x/4369673 to your computer and use it in GitHub Desktop.
def create
@errors = []
@user = User.authenticate(params[:username], params[:password])
respond_to do |format|
if @user.nil?
@errors << t("authentication_error")
format.html { render :new }
format.json { render json: @errors }
else
session[:user_id] = @user.id
format.html { redirect_to @user, notice: t("authenticated", nickname: @user.nickname) }
format.json { render json: @user, location: @user }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment