ruby - Stack Level Too Deep Error In Rails -
i'm getting error in rails , there's no other information me figure out why.
systemstackerror in usercontroller#students stack level deep
my user controller follows
class usercontroller < applicationcontroller before_filter :authenticate_user!, :except => [:show, :students, :mentors] ... def students @users = student.where(:verify_code => 'verified') end end
even when remove @users line error persists.
edit: error seems happen every single route aside devise_for :users
, to_root, means user controller.
user model
require 'json' require 'socket' class user < activerecord::base serialize :roles devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable validates :ign, :server, :roles, :presence => true validate :summoner_exists validate :valid_roles attr_accessible :email, :password, :password_confirmation, :remember_me, :ign, :server, :tier, :roles, :type def valid_roles valid_role_array = ['top', 'mid', 'jungle', 'ad carry', 'support'] self.roles.each |role| unless valid_role_array.include?(role) self.roles.delete(role) end end end def summoner_verified? return self.verify_code == 'verified' end def summoner_verify rune_pages = shurima_api(self.server, 'rune_pages', self.acctid) unless rune_pages return false else rune_pages.each |page| if (page['name'] == self.verify_code) self.verify_code = 'verified' self.save return true end end end return false end def summoner_exists json = shurima_api(self.server, 'summoner', self.ign) unless json errors.add(:ign, "the summoner name \"#{self.ign}\" doesn't exist on #{self.server}") else self.summonerid = json['summonerid'] self.acctid = json['acctid'] self.verify_code = array.new(10){rand(36).to_s(36)}.join eligible_to_mentor end end def eligible_to_mentor leagues = shurima_api(self.server, 'leagues', self.summonerid) unless leagues errors.add(:ign, "that summoner doesn't seem meet requirements become mentor. make sure you're @ least in platinum league") return false end leagues.each |league| if (league['queue'] == 'ranked_solo_5x5') self.tier = league['tier'] end end eligible_tiers = ['platinum', 'diamond', 'challenger'] if (self.type == 'mentor' && !eligible_tiers.include?(self.tier)) errors.add(:mentor, "mentors must @ least platinum.") end end def shurima_api(server, method, args) host, port = 'ip removed', 714 tcpsocket.open(host, port) |socket| ready = io.select([socket], [socket], nil, 8) return false unless ready socket.puts server + "&" + method + "&" + args.to_s message = socket.gets.chomp if message == '"unknown error"' return false end return json.parse(message) end end end
i ended fixing renaming request
method request_mentor
because causing infinite loop.
Comments
Post a Comment