impress/app/controllers/neopets_users_controller.rb

35 lines
951 B
Ruby
Raw Normal View History

2011-08-03 08:35:06 -07:00
class NeopetsUsersController < ApplicationController
before_filter :authenticate_user!, :build_neopets_user
rescue_from NeopetsUser::NotFound, :with => :not_found
def new
@neopets_user.username = current_user.neopets_username
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