Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6209325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:57:51+00:00 2026-05-24T05:57:51+00:00

When i am tring to retrive user information from mysql database, i am getting

  • 0

When i am tring to retrive user information from mysql database, i am getting some junk characters appended to the column values and some column values are not displayed – but the data is available in database.

Here is code which is used to retrive user info:

user_controller.rb
edit_user = User.find( params[:id])
@realname = edit_user.realname - value is displayed properly
@username = edit_user.username - value is displayed properly
@email = edit_user.email - value is displayed by junk characters - but value is not displayed in rails console and value can be seen in mysql database.

i.e. email value obtained is 0/, job_desc is 0/
Phone values as 1111/
addresses values as Office/

@phones = edit_user.phones
   @phones.each do |phone|
    if phone.phone_type == "Office"
        @phone1 = phone.number
    elsif phone.phone_type == "Mobile"
        @phone2 = phone.number
    elsif phone.phone_type == "Home"
        @phone3 = phone.number
    end
   end

user.rb - model:
class User < ActiveRecord::Base
     has_many :phones
    has_many :addresses
end
phone.rb
class Phone < ActiveRecord::Base
     belongs_to :user
end
address.rb
class Address < ActiveRecord::Base
     belongs_to :user
end

Can anyone guide me where i am making mistake or suggest me an approach to get user information properly without junk characters?

Thank u
Sudhir

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:57:53+00:00Added an answer on May 24, 2026 at 5:57 am

    I think there must be something going on outside the code you supplied.

    In rails console can you do the following…

    u = User.new
    u.realname = "1"
    u.username = "2"
    u.email = "test@something.com"
    u.save
    
    x = u.id
    
    u = User.find(x)
    puts x.email
    

    And post the results of this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to re-retrieve data from my database whenever the user clicks on
I've been trying to retrive attachment from message in Exchange 2003 server using WebDAV.
I am trying to code an simple PHP application which will retrieve some information
I am trying to pull out the information about each user group, while counting
I've been able to finally get python-openid to authenticate a user, but I'm not
I am trying to login and retrieve status information from a HTTPS URL via
I have a Java JDBC application that uses multiple threads to retrieve information from
With javax.security.Principal you can retrieve the user information at any point by injecting the
I am trying to retrieve some blob information using github rest api . Being

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.