I have an authorization control which requires current user name
(@currentuser.can_update?) to check permissions. The current user info
is taken from the sessions and if no user is logged in , i.e., is
session has a nil entry for user then I am assigning anonymous user as
if session[:user].nil? # used null object pattern
@currentuser = Anonymous.new
@currentusername = ‘Unassigned’
@currentrole = ‘anonymous’
@currentuser = User.find(session[:user])
@currentusername = @currentuser.username
@currentrole = @currentuser.role.name
The Anonymous class is a sub-class of user model. The problem is while
using wget or curl command. This occurred while testing and in
implementing functionality to generate static html archive.
I get an error like: ActiveRecord::StatementInvalid (Mysql::Error: MySQL
server has gone away: SHOW FIELDS FROM users):
This does not occur if I place my static archival code in models.
However, it spits out this error if static archival is done in
controller. So how should I implement this to set current user to logged
in or anonymous user?