1
0
Fork 0
forked from OpenNeo/impress
impress/app/controllers/neopets_users_controller.rb
Matchu d97c32b5da Upgrade to Rails 5.2.8.1
Some important little upgrades but mostly straightforward!

Note that there's still a known issue where item searches crash, I was hoping that this was a bug in Rails 4.2 that would be fixed on upgading to 5, but nope, oh well!

Also uhh I just got a bit silly and didn't actually mean to go all the way to 5.2 in one go, I had meant to start at 5.0… but tbh the 5.1 and 5.2 changes seem small, and this seems to be working, so. Yeah ok let's roll!
2023-10-23 19:05:05 -07:00

34 lines
959 B
Ruby

class NeopetsUsersController < ApplicationController
before_action :authenticate_user!, :build_neopets_user
rescue_from NeopetsUser::NotFound, :with => :not_found
def new
@neopets_user.username = current_user.contact_neopets_username
end
def create
@neopets_user.username = params[:neopets_user][:username]
@neopets_user.list_id = params[:neopets_user][:list_id]
@neopets_user.load!
@neopets_user.save_hangers!
flash[:success] = t('neopets_users.create.success',
:user_name => @neopets_user.username,
:count => @neopets_user.hangers.size)
redirect_to user_closet_hangers_path(current_user)
end
protected
def build_neopets_user
@neopets_user = NeopetsUser.new current_user
end
def not_found
flash.now[:alert] = t('neopets_users.create.not_found',
:user_name => @neopets_user.username)
render :action => :new
end
end