ruby on rails - Is possible to print a line in development logger? -


i have code users_controller.rb, need print line no 30 in development.log

line#29  def selectrole line#30    @userrole = rolesuser.find(:all, :conditions =>["p.user_id = ? , p.status = ? ",session[:user_id], params['status']]) line#31    logger.debug print_line(30) line#32  end 

can see 30th line in development.log this

@userrole = roleuser.find(:all, :conditions => ["p.user_id = ? , p.status = ? ", 1234, 'active']) 

what approach write "print_line" function? here print_line code?

def print_line(file_name, line)     counter = 1    printline = "-------- no such line --------"    file.open(file_name, "r") |infile|       while (line_text = infile.gets)          if counter == line             printline =  "#{counter} :: " +  line_text                 break          end           counter += 1       end    end    printline end 

from function getting this

 @userrole = rolesuser.find(:all, :conditions =>["p.user_id = ? , p.status = ? ",session[:user_id], params['status']]) 

is way find , replace variables respective values?

assuming you're interested in knowing contents of :conditions, why not this:

def selectrole   conditions = ["p.user_id = ? , p.status = ? ",session[:user_id], params['status']]   logger.debug(conditions)   @userrole = rolesuser.find(:all, :conditions => conditions) end 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -