1
0
Fork 0
forked from OpenNeo/impress
impress/app/controllers/neopets_users_controller.rb
Matchu 83bbb84382 Use flash[:notice] instead of flash[:success]
This is a bit more standard, and has the bonus of being compatible with Devise, which is using `flash[:notice]` and so its flashes were coming out unstyled, oops!
2023-10-23 19:05:07 -07:00

34 lines
958 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[:notice] = 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