Category: Ruby

  • Assets precompile without a database in Rails 4 and 5

    The other day I had a request from my IT guy. He asked: “Hey, can you make rails not connect to the database when running assets precompile?” I said sure… So why would we need to run a precompile without db connection? Well, for one thing, we are deploying to gcloud. For our current set…

  • Calculate the Size of Base64.strict_encode64 in Ruby

    I was in need to calculate the size of the output of Base64.strict_encode64. I wanted to get this value to determine if the file was too big to send to an API endpoint. If the file was too big I didn’t want to spend time processing and trying to send the data. So I put…

  • Invoking a Rake Multitask in a loop

    I am running selenium tests that I launch using a rake task. Recently I wanted to run a bunch on them concurrently every so often. The problem I ran into immediately, was that the tasks were only executed once. It turns out that, when calling a multitask multiple times, you not only have to .reenable…

  • TIL some awesome ActiveRecord behaviors in Rails

    So I started using rails about 3 months ago and it has been awesome. ActiveRecords was my first experience using ORM. I wish I had started using this a long time ago since using associations makes life so easy. As you read tutorials, there are many things that are left out. And unless you find…

  • Adding and Removing Children From a Form in Rails 4

    This is a topic that seems to get asked a lot and answered in so many different ways. I haven’t really found an answer that I considered full and easy to follow. Also, most answers were give for rails 3. So I decided I would share my implementation. I have made this project available in…

  • Handling dates when using Rails 4, bootstrap and bootstrap3-datetimepicker-rails gem

    The bootstrap3-datetimepicker-rails is a very nice plugin that adds a nice date and time picker to your bootstrap based rails application. I started using it the other day and I ran into huge problems. I will show you what I did and explain why I did it rather than explain the problems before hand.

  • Using Devise to create a new Copmany that a User belongs_to in Rails 4

    I was creating my first Rails app the other day and although the online tutorials are very useful, I couldn’t find a way to have my devise registration form create a new company and assign it to the new User. After a lot of googling and hair pulling I made it work. I created a…

  • Setting Up A Ruby On Rails Dev Enviroment in Ubuntu For PHP Developers

    So I am trying to jump on the ruby bandwagon and just spent a few days trying to understand how to configure a dev machine. Now, being a PHP developer I am spoiled by the relative easiness to set up a dev environment. The options are abundant: WAMP servers, the manual install is very easy,…