Mike's Blog

Passing on knowledge about software development and other related technologies.

Ruby On Rails Posts

Seeding your database in Rails - Part 2

In the first post about the seeds.rb file we covered the basics of how the seeds.rb file works. In this post, we will be looking at practical examples of how to use the seeds.rb file in a production situation. There are several issues you may have to deal with using the seeds.rb file in a project. First is determining if your data you are about to add to the database already exists. Let look at how we can do this.

first_or_create and find_or_create_by
There are two methods in Active Record that can be helpfu... Continue reading

Seeding your database in Rails - Part 1

When writing applications in Rails that use databases (as most do), we often have the need to populate small "reference" tables with data (like credit card types, colors, dog breeds, categories, etc) used in form drop-downs, test data when developing or inserting specific records into the database at deployment time. This is accomplished in Rails with the seeds.rb file located in the DB directory of your rails project folder. Surprisingly, most new Rails developers do not know about this file. If you open the file seeds.rb file in Rails 5.x you will see some examples of how you... Continue reading

My Thoughts about the RubyMine IDE

First let me note that I am in no way associated with JetBrains (the developers of RubyMine), just a loyal customer. As a long time developer on many platforms I have always thought Visual Studio was the most mature and well thought out IDE (Integrated development Environment) out "in the wild". Many products have tried to copy it's success across many different platforms but none has impressed me as much as RubyMine has since I started writing Ruby and Rails applications.

What makes RubyMine so special? Well lots of things, but most of all it helps you to be PRODUC... Continue reading