1
0
Fork 0
forked from OpenNeo/impress
impress/app/controllers/neopets_users_controller.rb

35 lines
959 B
Ruby
Raw Normal View History

2011-08-03 08:35:06 -07:00
class NeopetsUsersController < ApplicationController
before_action :authenticate_user!, :build_neopets_user
2011-08-03 08:35:06 -07:00
rescue_from NeopetsUser::NotFound, :with => :not_found
def new
@neopets_user.username = current_user.contact_neopets_username
2011-08-03 08:35:06 -07:00
end
def create
@neopets_user.username = params[:neopets_user][:username]
2013-08-17 09:07:04 -07:00
@neopets_user.list_id = params[:neopets_user][:list_id]
2011-08-03 08:35:06 -07:00
@neopets_user.load!
@neopets_user.save_hangers!
2013-01-01 19:45:15 -08:00
flash[:success] = t('neopets_users.create.success',
:user_name => @neopets_user.username,
:count => @neopets_user.hangers.size)
2011-08-03 08:35:06 -07:00
redirect_to user_closet_hangers_path(current_user)
end
protected
def build_neopets_user
@neopets_user = NeopetsUser.new current_user
end
def not_found
2013-01-01 19:45:15 -08:00
flash.now[:alert] = t('neopets_users.create.not_found',
:user_name => @neopets_user.username)
2011-08-03 08:35:06 -07:00
render :action => :new
end
end