Book Image

Instant RubyMine Assimilation

By : David L. Jones
Book Image

Instant RubyMine Assimilation

By: David L. Jones

Overview of this book

Ruby and Ruby on Rails applications can become very complex very quickly, with hundreds of different files to contend with during a typical day of development. With RubyMine, you can become much more productive and let the IDE take care of the menial tasks while you concentrate on the details and structure of your applications. Instant RubyMine Assimilation shows you how to integrate the RubyMine development environment into your everyday development process. With step-by-step instructions and practical examples, you will learn how to customize the environment precisely to suit your needs, debug and test your code, and get the most out of many other features of RubyMine. Starting with the installation of RubyMine on your preferred platform, this guide will walk you through creating your first program. You will be taken through everything from the development and testing process all the way to deploying your website for the world to enjoy. You will learn how to manage your project in RubyMine including integrating version control, testing, and debugging your projects. Furthermore, you will learn how to navigate complex projects, view database tables, and utilize the built-in console and deployment tools of RubyMine, all of which will help you become an expert developer This book will also teach you how to install and use Gems, change Ruby environments, and use code coverage and reports to enhance your testing. By the end of this book, you will be able to confidently deploy your Rails application to a server, all within the inviting environment that is RubyMine.
Table of Contents (7 chapters)

Monitoring your extremities (Become an expert)


RubyMine has more tools that let us manage all aspects of our programming projects. This recipe will concentrate on configuring and using the built-in database tools in RubyMine.

Getting ready

Open your Progeny Rails project that we created earlier in RubyMine.

When the project opens, there will likely be a window that comes open like the following:

Click on the link and RubyMine will download and install some Java database drivers so that it can access your Sqlite database (or whichever you are using) from your existing Rails project.

How to do it...

Directly accessing your database fields and structure is much more efficient when we have a nice tool to list and modify our records. RubyMine has the ability to show the tables from your environment directly in the interface, so there is no need to open another tool. Perform the following steps for monitoring your extremities:

  1. Click on the Database button on the left side of the RubyMine main frame. This will open a panel that looks like the following:

  2. Click on the panel and then use the command code as described in the window. (This will be different for each operating system).

  3. Select the menu item Import from sources … and then hit OK from the next window.

  4. Click on the table that shows and open up each level.

  5. Double-click on the id element of the Species table and we will see a window like the following:

    This allows us to view, add, modify, and delete records from our tables easily.

  6. Click on the + icon, we will then be able to manually add another record to our database.

    If we double-click on one of the cells, we can modify the values that are stored in the database. This is a quick way to edit some mistakes that we made when entering data or to test out a part of our interface. Let's add another record via the table editor.

  7. Click on the + icon and enter the following information into the cells of the new blank row that is created:

  8. Now we have two species in our database. We can edit these items as we please, but please note that updates do not automatically change the updated_at field. This is done through the Rails system as it saves a record and we are bypassing that framework completely using this system. We are talking directly to the database.

  9. RubyMine also gives us a nice interface to perform direct database queries on our data tables directly.

  10. Open the database console by hitting the icon Database Console at the top of the Database panel. This opens a window in the main editor panel that lets us type SQL queries directly and execute them to get a dataset back, as you can see in the following screenshot:

  11. Type the following in the console window:

    select * from species where assimilated = 'f'
    
  12. Select the green arrow button right above the text in the editor panel. Don't select the green arrow which runs a specific configuration.

    The results of this direct query will now show at the bottom in a new panel with a database table editor like we had before. It will look something like the following screenshot:

    We selected all of the species in our table that have not yet been assimilated. We can now remedy that easily.

  13. Double click on the f letter in the assimilated column.

  14. Change that to t.

See how easy it is to assimilate other species?

Notice that when you changed the field, it disappeared. This is because our query was executed again and found no more species left to assimilate in our database table. Our job is done. We can return to the collective.