/ RAILS

Rails meta_request gem and Rails Panel

meta_request gem is used with Rails application for profiling and performance improvement. This gem is used with Rails Panel chrome extension. This tutorial will help you understand how to use both for profiling and performance improvement of your Rails Applications.

1. Rails Panel

To begin with you need to install Chrome Extension Rails Panel first.

Link: Rails Panel - Chrome

After installing this extension you will be able to see the ‘Rails’ tab is added in your chrome inspect section as you can see in the image below.

meta_request gem

This image show various columns and stats tabs that this extension supports for the profiling of your Rails Applications.

2. meta_request gem

Step 1. Install gem

After successfully completing step 1 you can install the gem meta_request on your machine.

Gem meta_request can be installed using following command,

gem install meta_request
Fetching: meta_request-0.3.0.gem (100%)
Successfully installed meta_request-0.3.0
Parsing documentation for meta_request-0.3.0
Installing ri documentation for meta_request-0.3.0
Done installing documentation for meta_request after 0 seconds
1 gem installed

This command will install the latest stable version of the gem on your local machine.

Step 2. Add to Gemfile

After successfully installing the gem, you need to add this gem in Gemfile of your Rails Application.

This can be done by adding following line to Gemfile

group :development do
  gem 'meta_request'
end

This will add the gem in group development environment. This sets the gem to be used in the development environment of your Rails Application.

Step 3. Test the gem

Now, you can run your Rails Application to see whether gem is giving profiling result for Rails Application.

Start your Rails application with Rails Panel console open in Chrome Browser.

Brief abouts Tabs -

Breakdown -

This shows how much time was taken by ActiveRecord (Backend Processing), Rendering of ERB (Front-end) and other processing.

Params -

You can inspect which parameters are being passed to your Controller and Actions.

ActiveRecord -

This tab will show you exactly which queries are executed by your Rails application. This is very much useful for Query Optimization in Rails

Log -

This will print any logs that you have put in your codebase. This will also show the exact line numbers from the codebase which outputs these logs.

Error -

This prints errors if there are any.

Conclusion -

  • The meta_request gem can be used for in-browser understanding/profiling of Rails Applications
  • You can explore this tool more to use it to for profiling better in Rails Applications.

For more on profiling inside your browser for Rails Application, you might want to explore this Firefox Addon - RailsBug

akshay

Akshay Mohite

Hi there! I am a Ruby on Rails & ReactJS Enthusiast, building some cool products at DTree Labs.

Read More
Buy me a coffee