Reader small image

You're reading from  Instant RubyMine Assimilation

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781849698764
Edition1st Edition
Languages
Right arrow
Author (1)
David L. Jones
David L. Jones
author image
David L. Jones

Dave Jones is a developer and teacher living in Spokane, Washington. He has worked with many of the top Fortune 500 companies during the last 30 years of his career. Dave has a Bachelor of Science degree in Computer Science from Cal Poly, Pomona and has a Masters of Technology Management degree from Pepperdine University. He has always had a love for computers. He started his career by fixing Apple computers in the early 1980s. He continued on his career path by working at Rockwell Space Division where he had the opportunity to work on various Space Shuttle ground and control systems. Dave continued his varied career by entering into the burgeoning Internet software industry, where he worked on developing white-label forum/bulletin board systems for many different startup companies. Some of these companies included Apple Computer, Microsoft, WebMD, Cisco, New York Times, UK Guardian, Dr. Phil and Oprah shows, Citicorp, Reader's Digest, Edmunds.com, Sony, Kodak, and many other fortune 500 companies. Throughout this interesting career, he was able to learn many of the technologies that are in use today and decided that he wanted to give back to the software community by teaching some of his life-long skills to new developers beginning their new careers. Dave began teaching at a Spokane Community college in the Software Development department in 2008. He currently teaches many different technologies including Ruby, Ruby on Rails, PHP, Agile development, CSS/HTML, JavaScript, jQuery, mobile development with Java on the Android OS, as well as Objective-C on Apple iOS devices. He records his lectures and makes them publically available on YouTube where thousands of developers around the world are benefiting from his expertise. He is also the owner of a small software consulting company that helps pay for his teaching hobby. Dave has a passion for computers, Internet, and building software. He truly enjoys the interaction and satisfaction that comes from the creation of software tools.
Read more about David L. Jones

Right arrow

Manipulating your tech (Become an expert)


This recipe will show you how to start the Rails console and inspect your code and database interactively.

Getting ready

Open your Progeny Rails project in RubyMine.

How to do it...

RubyMine allows you to run both the Interactive RuBy (IRB) console as well as the Ruby on Rails console. They both run in an interactive window at the bottom of your editor much like the debugger and output windows. Perform the following steps:

  1. On the Tools menu, select Run Rails Console and RubyMine will ask you which environment you would like to load into the console. This lets you inspect/change your debug, test, or production environments directly. The default option gives the development environment.

  2. Select OK and the console will open.

    The Rails console prompt >> means that it is ready for input from the keyboard.

    Type 2 + 2 and hit Return. The result should be 4 as you can see in the following screenshot. This is just like the IRB console, in that you can type Ruby expressions and they will be evaluated interactively.

  3. Let's perform some database lookups using Rails syntax.

  4. The proper syntax for Rails 4.0 is something like the following, which you can type in and see the result:

    Species.where(assimilated: true).load

    The result will be something like this:

      Species Load (0.2ms)  SELECT "species".* FROM "species" WHERE "species"."assimilated" = 't'
    #<ActiveRecord::Relation [#<Species id: 3, name: "Human", identification: 5618, assimilated: true, created_at: "2013-06-03 00:58:57", updated_at: "2013-06-03 00:58:57">]>

How it works…

We can see that the console returned an array of Species objects that matched that query. It even showed us the SQL query that was used to get the data directly from the database.

There are many wonderful tutorials and tricks online that we can make use of to learn more about the console, starting with the official Rails Guides: http://guides.rubyonrails.org/.

Previous PageNext Page
You have been reading a chapter from
Instant RubyMine Assimilation
Published in: Nov 2013Publisher: PacktISBN-13: 9781849698764
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
David L. Jones

Dave Jones is a developer and teacher living in Spokane, Washington. He has worked with many of the top Fortune 500 companies during the last 30 years of his career. Dave has a Bachelor of Science degree in Computer Science from Cal Poly, Pomona and has a Masters of Technology Management degree from Pepperdine University. He has always had a love for computers. He started his career by fixing Apple computers in the early 1980s. He continued on his career path by working at Rockwell Space Division where he had the opportunity to work on various Space Shuttle ground and control systems. Dave continued his varied career by entering into the burgeoning Internet software industry, where he worked on developing white-label forum/bulletin board systems for many different startup companies. Some of these companies included Apple Computer, Microsoft, WebMD, Cisco, New York Times, UK Guardian, Dr. Phil and Oprah shows, Citicorp, Reader's Digest, Edmunds.com, Sony, Kodak, and many other fortune 500 companies. Throughout this interesting career, he was able to learn many of the technologies that are in use today and decided that he wanted to give back to the software community by teaching some of his life-long skills to new developers beginning their new careers. Dave began teaching at a Spokane Community college in the Software Development department in 2008. He currently teaches many different technologies including Ruby, Ruby on Rails, PHP, Agile development, CSS/HTML, JavaScript, jQuery, mobile development with Java on the Android OS, as well as Objective-C on Apple iOS devices. He records his lectures and makes them publically available on YouTube where thousands of developers around the world are benefiting from his expertise. He is also the owner of a small software consulting company that helps pay for his teaching hobby. Dave has a passion for computers, Internet, and building software. He truly enjoys the interaction and satisfaction that comes from the creation of software tools.
Read more about David L. Jones