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 218885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:47:35+00:00 2026-05-11T18:47:35+00:00

The Rails console doesn’t seem to like multiple ruby statements on the same line

  • 0

The Rails console doesn’t seem to like multiple ruby statements on the same line separated by a semicolon. Whenever I do this, the next line starts with ?> and I find that only the first statement was executed. Do you have to put each statement on a separate line?

>> user = User.new
user = User.new

=> #<User id: nil, username: "", hashed_password: "", first_name: "", last_name: "", email: "", display_name: "", user_level: 0, created_at: nil, updated_at: nil, posts_count: 0>

>> user.username = "John"; hashed_password = "John"; first_name = "John"; last_name = "coltrane"; email = "John@coltrane.com"; display_name = "Johndispay"; user_level = 9; 
user.username = "John"; hashed_password = "John"; first_name = "John"; last_name = "coltrane"; email = "John@coltrane.com"; display_name = "Johndispay"; user_level = 9; 

?> user.save
user.save

=> true

Everything except user.username = "John"; was ignored

  • 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-11T18:47:36+00:00Added an answer on May 11, 2026 at 6:47 pm

    You need to say “user.” so Ruby knows you mean to call the attribute assignment methods of the instance of user. Otherwise, you are just setting local variables called “hashed_password”, etc.

    >> user.username = "John"; user.hashed_password = "John"; user.first_name = "John"; user.last_name = "coltrane"; user.email = "John@coltrane.com"; user.display_name = "Johndispay"; user.user_level = 9; 
    

    Although, you could just pass a hash of the attributes you want to set on the new instance, like so

    >> user = User.new(:username => "John", :hashed_password => "John", ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 99k
  • Answers 99k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It should work - as long as the data variable… May 11, 2026 at 7:49 pm
  • Editorial Team
    Editorial Team added an answer There is a bunch of them, try these ones for… May 11, 2026 at 7:49 pm
  • Editorial Team
    Editorial Team added an answer SELECT id, name FROM mytable WHERE name IN ('B', 'A',… May 11, 2026 at 7:49 pm

Related Questions

Open up a Rails console and enter this: 2.weeks.ago.between? 2.weeks.ago, 1.week.ago Did it give
I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries
I'm trying to get tags working in my rails application and want to use
I have a model called TipoContato (table tipos_contato), if I pluralize this it will
SORRY:: I forgot that params[:user_id] does not exist in the controller, using current_user.id !

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.