I found a gem that’s helping me a bunch, so I just wanted to give it a quick mention. After asking people for help on a N+1 query that I couldn’t figure out, one of the people recommended checking out the Goldiloader gem.
I was so impressed that the gem solved my N+1 query so easily, I decided to use it across my site.
It’s ridiculously simple to use once you have model associations defined.
All you need to do is to add the gem to your gemfile and it does the eager loading for you! If there are places you want to avoid eager loading, you can disable Goldiloader for a query.
ActiveAdmin is my favorite gem for creating admin features in Rails. It makes it so easy to create views to monitor and manage apps. Much of the heavy lifting is done for you by them gem.
I found that I need to do some tuning on my ActiveAdmin views to get the functionality I wanted without placing too heavy a burden on my server.
I mainly did this by doing two simple things:
(1) Specify Filters – if you don’t specify your filters, you may get far too many (and consuming too many resources when you don’t need to). Specifying filters are easy, just go into you admin files for the resource (i.e. app > admin > article.rb), then add a line for each filter you want
(2) Specify Index (and other) Columns – similar to above, if you don’t specify values, you may be receiving too much data. Be more efficient by only showing what you need to see in a view.
You can do this in your admin file for a resource, simply by adding this:
I was having trouble figuring out how to dump the data from PostgreSQL with PGAdmin until I have this on PostgreSQL Tutorial.
Following the directions, I was able to do a dump as .tar file. They also have instructions on how to restore it.
I found a great article on sorting bootstrap tables without any gems or additional libraries. Check it out here.
I had some fields that were sensitive, so I didn’t want the values appearing in the logs. The solution was filtering them. Doing that was easy.
In config/initializers/filter_parameter_logging.rb, and your fields, like so:
Rails.application.config.filter_parameters += [:password, :secret_field]
Now, when I look at the logs, I see this: