{"id":3501,"date":"2022-07-06T07:00:42","date_gmt":"2022-07-06T14:00:42","guid":{"rendered":"http:\/\/www.codingdojo.com\/blog\/?p=3501"},"modified":"2022-10-07T15:43:54","modified_gmt":"2022-10-07T22:43:54","slug":"ruby-on-rails-examples","status":"publish","type":"post","link":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples","title":{"rendered":"Ruby on Rails Examples to Consider for Your Developmental Journey"},"content":{"rendered":"<p>Ruby on Rails continues to be an extremely powerful yet developer-friendly solution for tackling all manner of web projects, and this trend doesn&#8217;t appear to be abating anytime soon.\u00a0 Due to Rails&#8217; insistence of &#8220;<a href=\"https:\/\/rubyonrails.org\/\">convention over configuration<\/a>&#8220;, however, it can often be difficult to precisely determine how you should go about solving a particular problem or what the Ruby on Rails best practices might actually be as the technology rapidly changes from year to year and from version to version.<\/p>\n<p>While Rails is far too massive a topic to cover everything, in this article we&#8217;ve assembled some of the most fundamental Ruby on Rails Examples for 2022 as you embark on your own development journey with Rails and the amazing possibilities with which that entails.<\/p>\n<h2>Ruby on Rails Examples: What You Need to Know<\/h2>\n<h3>1. Jump Start with Scaffolding<\/h3>\n<p><a href=\"https:\/\/guides.rubyonrails.org\/v3.2.13\/getting_started.html#getting-up-and-running-quickly-with-scaffolding\" target=\"_blank\" rel=\"noopener noreferrer\">Scaffolding<\/a> is a great feature of Rails for individuals new to the development, or perhaps those just new to Rails itself. Scaffolding is one of the many generate commands that allows you to automatically create all the framework files you need for a simple object, including the model, controller, database migration file, and basic views.<\/p>\n<p>For example, if you want to create a simple Book model and all associated components, you might run the following command in the terminal.<br \/>\n<img decoding=\"async\" class=\"aligncenter wp-image-3503 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg\" alt=\"Ruby on Rales scaffolding example\" width=\"824\" height=\"45\" \/><br \/>\nHere we&#8217;re asking rails to generate a scaffold object called Book and then specifying the model fields afterward in the format of field_name:data_type.<\/p>\n<p>You should immediately see an output with all the generates files and paths.<br \/>\n<img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-3504 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/32.jpg\" alt=\"Ruby on Rales scaffolding\" width=\"526\" height=\"223\" \/><br \/>\nBelieve it or not, you now technically have a working rails application!\u00a0 You can run your rails server ($ rails s)\u00a0 and browse to your localhost to see your functional page.\u00a0 It won&#8217;t be pretty, but as is the beauty of Rails, it should just work out of the box with the fields behaving as you expect.<\/p>\n<p>While scaffolding is a great jumping-off point for developers still learning Rails, much of the code generated by the scaffold command will be wasted or not appropriate for most projects, so be weary of all the files and code created when running this command in your own projects.<\/p>\n<h3>2. Properly Associating Many to Many<\/h3>\n<p>During development, you may find you need to associate two models through a many-to-many relationship, whereby each instance of a model can be matched with any number of instances of the other model, and vice versa.<\/p>\n<p>There are essentially two methods by which to create such an association, so we&#8217;ll briefly discuss both options and why one method in particular (has_many :through) is the far superior implementation.<\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h5><strong>The has_and_belongs_to_many Association<\/strong><\/h5>\n<\/li>\n<\/ul>\n<p>For a truly basic many-to-many relationship of two models, you can declare a <a href=\"https:\/\/guides.rubyonrails.org\/association_basics.html#the-has-and-belongs-to-many-association\" target=\"_blank\" rel=\"noopener noreferrer\">has_and_belongs_to_many<\/a> association in both models, like so:<br \/>\n<img decoding=\"async\" class=\"aligncenter wp-image-3505 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/33.jpg\" alt=\"Ruby on Railes many to many\" width=\"701\" height=\"148\" \/><br \/>\nThis would then require you to create a simple database table to represent that relationship.\u00a0 Your migration file would look something like this:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3507 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/35.jpg\" alt=\"Properly Associated ruby on Railes\" width=\"522\" height=\"155\" \/><br \/>\nNow, in addition to the separate authors and books tables, you also have the authors_books table that simply has two columns to associate the id field of one author and one book.\u00a0 An instance of a model can then reference the other through this association:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3549 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/NEEDED-now.jpg\" alt=\"Ruby on Rales column\" width=\"843\" height=\"97\" \/><\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h5><strong>Why the has_many: through Association Wins<\/strong><\/h5>\n<\/li>\n<\/ul>\n<p>While has_and_belongs_to_many is sufficient for the most rudimentary many-to-many relationship, it&#8217;s a very weak and limited solution, particularly for future-proofing.<\/p>\n<p>The biggest limitation with the has_and_belongs_to_many association is that the associative model it creates &#8212; authors_books in our example above &#8212; has no room for expansion in the future.\u00a0 Later in development, imagine we need a model field that indicates which chapter(s) of a book a particular author worked on.<\/p>\n<p>With has_and_belongs_to_many, there&#8217;s no simple way to track that information, because neither the books nor authors database table would allow for storage of all the necessary information (the book plus the author plus the chapters).\u00a0 Suddenly, the has_and_belongs_to_many association we&#8217;re using needs to be scrapped or a huge workaround needs to be figured out so we don&#8217;t screw up live data.<\/p>\n<p>Enter the far superior solution of the <a href=\"https:\/\/guides.rubyonrails.org\/association_basics.html#the-has-many-through-association\" target=\"_blank\" rel=\"noopener noreferrer\">has_many :through<\/a> association.\u00a0 This model configuration utilizes not only a third database table but most importantly, also utilizes a third model <em>through which<\/em> the two base models can be associated with one another.\u00a0 With access to the third &#8220;connector&#8221; model, we now have the freedom to add attribute fields or any other logic we might need in the future.<\/p>\n<p>To use the has_many :through association for our example, we&#8217;d do something like this:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3509 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/37.jpg\" alt=\"Ruby on rails association example\" width=\"494\" height=\"276\" \/><br \/>\nWith the authorship model in place for our many-to-many relationship between books and authors, we can now easily modify the authorship model in the future, adding a column for :edited_chapters or anything else we might need.<\/p>\n<p>In short, while it requires a bit more time and effort to initially setup, you should <strong>always<\/strong> use the has_many :through association anytime a many-to-many relationship is required.<\/p>\n<h3>3. Generating Initial Database Data<\/h3>\n<p>While most data during development can be generated on the fly during your testing procedures, you may often find yourself in a situation where you need specific dummy data to fill up your database while you work and tweak your code or even data for the live environment. Luckily, the <a href=\"http:\/\/www.xyzpub.com\/en\/ruby-on-rails\/3.2\/seed_rb.html\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>db\/seeds.rb<\/strong><\/a> file exists exactly for this purpose.<\/p>\n<p>Since seeds.rb is of course a Ruby file, it can contain almost any Ruby code you need in order to create your initial data.\u00a0 For example, our books project might add a couple books and authors like so:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3510 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/39.jpg\" alt=\"Ruby on Rails database generation\" width=\"773\" height=\"454\" \/><br \/>\nOnce you have some code in seeds.rb to generate data, you can populate your database from the terminal:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3511 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/40.jpg\" alt=\"Ruby on Rails seeds.gb\" width=\"805\" height=\"42\" \/><br \/>\nThere are even great Ruby gems like the <a href=\"https:\/\/github.com\/faker-ruby\/faker\" target=\"_blank\" rel=\"noopener noreferrer\">Faker<\/a> gem for creating more realistic dummy data such as names, colors, and URLs.<\/p>\n<h3>4. Utilize Active Record Validations<\/h3>\n<p>All applications &#8212; particularly web applications that accept user data &#8212; need a solid foundation of data validation, and <a href=\"https:\/\/guides.rubyonrails.org\/active_record_validations.html\" target=\"_blank\" rel=\"noopener noreferrer\">directly within the model<\/a> is a great place to perform these initial validations.\u00a0 Proper validation will ensure that only valid data is processed and ultimately saved to your database.<\/p>\n<p>Rails offers plenty of <a href=\"https:\/\/guides.rubyonrails.org\/active_record_validations.html#validation-helpers\" target=\"_blank\" rel=\"noopener noreferrer\">built-in validation helpers<\/a>, or you can even create your own <a href=\"https:\/\/guides.rubyonrails.org\/active_record_validations.html#performing-custom-validations\" target=\"_blank\" rel=\"noopener noreferrer\">custom validation<\/a>, so there&#8217;s no excuse not to validate your data as accurately as possible before saving it to the database.<\/p>\n<p>As a simple example, here we&#8217;re validating that our book title exists and is no larger than 255 characters.\u00a0 We&#8217;re also validating that the ISBN is a unique integer between 10 and 13 characters.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3517 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/45.jpg\" alt=\"Ruby on Rails activate record\" width=\"488\" height=\"262\" \/><\/p>\n<h3>5. Robust Models and Tiny Controllers<\/h3>\n<p>It is typically the best practice in Rails to keep the majority of your business logic and execution within your models, and thus away from your controllers.\u00a0 That isn&#8217;t to say the paradigm of developing &#8220;fat models&#8221; is necessarily appropriate in all cases, and of course, your design pattern should be based on the needs of the project.<\/p>\n<p>Yet, at the very least, the concept of tiny controllers (and by extension, fewer objects passed to your views) is a good practice to get into.\u00a0 To achieve this, you need look no further than using a <a href=\"http:\/\/wiki.c2.com\/?FacadePattern\" target=\"_blank\" rel=\"noopener noreferrer\">facade pattern<\/a>, which effectively provides a higher-level interface that can aggregate important functionality and pass that interface along to lesser interfaces.<\/p>\n<p>In the case of Rails, this means creating a facade class that exposes a variety of methods and objects needed in a particular view, without requiring the controller to directly access all of these methods and objects individually.<br \/>\n<em>Here&#8217;s a simple example of using a facade in our Book Dojo application:<\/em><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3518 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/46.jpg\" alt=\"Ruby on Rails models\" width=\"477\" height=\"261\" \/><br \/>\nA basic example, but here we have the Library class with acts as a facade to gather information about the current user along with his or her favorite authors and owned books.<\/p>\n<p>We can then simply pass that information along to the controller that will make use of it with only one single instance object, @library.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3519 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/47.jpg\" alt=\"Ruby on Rails models examples\" width=\"585\" height=\"133\" \/><br \/>\nNow, the view of the home page that renders this also needs only to receive one instance object of @library, and can invoke the methods therein to get the appropriate information.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3520 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/48.jpg\" alt=\"Ruby on Rails rendering\" width=\"628\" height=\"75\" \/><br \/>\nWhile this is a simple example, it should give you an idea of how a <a href=\"https:\/\/thoughtbot.com\/blog\/sandi-metz-rules-for-developers#only-instantiate-one-object-in-the-controller\" target=\"_blank\" rel=\"noopener noreferrer\">facade pattern<\/a> can clean up your controllers and views considerably.<\/p>\n<h4>6. Properly Managing Dates, Times, and Timezones<\/h4>\n<p>While Rails offers a number of useful classes and methods for manipulation of dates and times, it is not uncommon for developers to run into inconsistencies and issues when timezones begin to enter into the mix.\u00a0 Even for applications developed without a requirement of timezone support, often an application is actually dealing with a multitude of possible timezones.<\/p>\n<p>Your Rails application will often need to correctly account for the timezone of the server running rails, the database server, and the Rails application itself.<\/p>\n<p>To deal with these potential pitfalls, there are a few simple practices that you should begin implementing in your own development.<\/p>\n<ul style=\"list-style-type: circle;\">\n<li><strong>Application Timezone<\/strong><\/li>\n<\/ul>\n<p>Begin by setting the timezone of your application, which can be done in the config\/application.rb file using the <a href=\"https:\/\/api.rubyonrails.org\/classes\/ActiveSupport\/TimeZone.html\" target=\"_blank\" rel=\"noopener noreferrer\">config.time_zone<\/a> method.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3521 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/49.jpg\" alt=\"Ruby on Rails timezone management\" width=\"525\" height=\"131\" \/><br \/>\nTo see a list of appropriate timezone names, use the rake time:zones:all command in the terminal.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3522 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/50.jpg\" alt=\"Ruby on Rails timezone example\" width=\"545\" height=\"46\" \/><\/p>\n<ul style=\"list-style-type: circle;\">\n<li><strong>ActiveRecord &amp; UTC Conversion<\/strong><\/li>\n<\/ul>\n<p>Rails stores all dates and times in the database in UTC.\u00a0 With config.time_zone set for your application, Rails will attempt to convert ActiveRecord attributes from the UTC stored in the database to your application timezone.\u00a0 This means if you retrieve a time attribute from an ActiveRecord instance, the timezone will be automatically converted to the application timezone before being output:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3523 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/511.jpg\" alt=\"Ruby on Rails timezone config\" width=\"609\" height=\"39\" \/><br \/>\nIf config.time_zone is unspecified, you&#8217;ll get the actual stored database value, which is in UTC:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3524 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/52.jpg\" alt=\"Ruby on Rails timezone\" width=\"622\" height=\"61\" \/><\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h4>Use the Time Class, Not Date<\/h4>\n<\/li>\n<\/ul>\n<p>If at all possible, always try to utilize the <a href=\"https:\/\/api.rubyonrails.org\/classes\/Time.html\" target=\"_blank\" rel=\"noopener noreferrer\">Time<\/a> class in Rails instead of <a href=\"https:\/\/api.rubyonrails.org\/classes\/Date.html\" target=\"_blank\" rel=\"noopener noreferrer\">Date<\/a>.\u00a0 This is simply because Date doesn&#8217;t innately manage time information, whereas the Time class does so, as expected.<\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h4>Parsing Input Times<\/h4>\n<\/li>\n<\/ul>\n<p>When you need to parse a date and time from another source, always use Time.zone.parse (instead of Time.parse) to make use of the timezone specified in your application&#8217;s configuration.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3525 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/53.jpg\" alt=\"Ruby on Rails parsing\" width=\"563\" height=\"49\" \/><\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h4>Beware of Database Engine and Time Comparisons<\/h4>\n<\/li>\n<\/ul>\n<p>Be particularly mindful when performing comparisons of times from two different sources, since the comparison you expect may not actually be taking place.<\/p>\n<p>For example, imagine a real-world scenario where your application needs to compare a date and time stored in the database with a date and time specified by the user.\u00a0 The user will, of course, use a datepicker object and provide your application with a date and time with precision up to the second if you require it.\u00a0 The user input that is processed by your application might look something like this:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3526 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/54.jpg\" alt=\"Ruby on Rails database time\" width=\"524\" height=\"48\" \/><br \/>\nIn the application code, you might parse that user-input time like so:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3527 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/55.jpg\" alt=\"Ruby on Rails user input\" width=\"518\" height=\"63\" \/><br \/>\nNow, if your application attempts to compare the time parsed from the user above with the same date and time from a record in the database, you will often find that the two times do not, in fact, match as you would expect, in spite of being identical down to the second.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3529 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/56.jpg\" alt=\"Ruby on Rails parse\" width=\"568\" height=\"130\" \/><br \/>\nThe issue here is that the database (in this case SQLite) may actually store time values with <strong>microsecond precision<\/strong>, whereas the user-specified time of course only has precision to the second.\u00a0 This difference can be seen by converting the times to floating point numbers:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3530 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/57.jpg\" alt=\"Ruby on Rails SQLite\" width=\"550\" height=\"102\" \/><br \/>\nTo resolve this issue, be sure to convert your times to the appropriate precision first before making any comparisons.\u00a0 In the above example, if we only need to compare to the <em>second<\/em>, then the simplest option is to convert both times to integers, which is effectively evaluating the number of seconds in total:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3531 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/58.jpg\" alt=\"Ruby on Rails time\" width=\"520\" height=\"129\" \/><br \/>\nOn the flipside, also be aware of your database engine and what kind of time precision it is storing by default.\u00a0 This is particularly crucial for MySQL, which as of <a href=\"https:\/\/dev.mysql.com\/doc\/relnotes\/mysql\/5.6\/en\/news-5-6-4.html\" target=\"_blank\" rel=\"noopener noreferrer\">version 5.6.4<\/a> has support for times with fractional seconds, but you must configure your database to do so.\u00a0 See <a href=\"https:\/\/gist.github.com\/iamatypeofwalrus\/d074d22a736d49459b15\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<h4>Date and Time Cheat Sheet<\/h4>\n<p>To recap, here are a few good and bad practices working with time in Rails.<\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h5>The Good<\/h5>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3532 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/59.jpg\" alt=\"Good Ruby on Rails time code\" width=\"702\" height=\"270\" \/><\/p>\n<ul style=\"list-style-type: circle;\">\n<li>\n<h5>The Bad<\/h5>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3551 size-full\" src=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/Capture.jpg\" alt=\"Bad Ruby on Rails time code\" width=\"936\" height=\"178\" \/><\/p>\n<h2>Looking for more \u00a0Ruby on Rails examples?<\/h2>\n<p><span style=\"font-size: 14pt;\">Ruby on Rails at Coding Dojo<\/span><\/p>\n<p style=\"text-align: left;\">Any of Coding Dojo&#8217;s four software development bootcamps can help you learn more about implementing Ruby on Rails? Which coding bootcamp is right for you?<\/p>\n<ul>\n<li><a href=\"https:\/\/www.codingdojo.com\/coding-bootcamp\">On-Site Full-Time (14 Weeks)<\/a><\/li>\n<li><a href=\"https:\/\/www.codingdojo.com\/online-coding-bootcamp-full-time\">Online Full-Time (14 Weeks)<\/a><\/li>\n<li><a href=\"https:\/\/www.codingdojo.com\/online-coding-bootcamp-flex-part-time\">Online Part-Time Flex (28 Weeks)<\/a><\/li>\n<li style=\"text-align: left;\"><a href=\"https:\/\/www.codingdojo.com\/online-coding-bootcamp-part-time\">Online Accelerated (16-32 Weeks)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ruby on Rails continues to be an extremely powerful yet developer-friendly solution for tackling all manner of web projects, and this trend doesn&#8217;t appear to be abating anytime soon.\u00a0 Due to Rails&#8217; insistence of &#8220;convention over configuration&#8220;, however, it can often be difficult to precisely determine how you should go about solving a particular problem [&hellip;]<\/p>\n","protected":false},"author":1367,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2],"tags":[],"ppma_author":[156],"class_list":["post-3501","post","type-post","status-publish","format-standard","hentry","category-posts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ruby on Rails Examples to Consider | Coding Dojo<\/title>\n<meta name=\"description\" content=\"Read on to learn more about the most fundamental Ruby on Rails examples for 2020 as you embark on your own development journey with Rails\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ruby on Rails Examples to Consider | Coding Dojo\" \/>\n<meta property=\"og:description\" content=\"Read on to learn more about the most fundamental Ruby on Rails examples for 2020 as you embark on your own development journey with Rails\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\" \/>\n<meta property=\"og:site_name\" content=\"Coding Dojo\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CodingDojodotco\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-06T14:00:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-07T22:43:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/BlogImg_Ruby_600x350.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Speros Misirlakis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodingDojoDotCo\" \/>\n<meta name=\"twitter:site\" content=\"@CodingDojoDotCo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Speros Misirlakis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\"},\"author\":{\"name\":\"Speros Misirlakis\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#\/schema\/person\/d916946be07d898fdf93ae96664934a3\"},\"headline\":\"Ruby on Rails Examples to Consider for Your Developmental Journey\",\"datePublished\":\"2022-07-06T14:00:42+00:00\",\"dateModified\":\"2022-10-07T22:43:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\"},\"wordCount\":2090,\"publisher\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg\",\"articleSection\":[\"All Posts\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\",\"url\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\",\"name\":\"Ruby on Rails Examples to Consider | Coding Dojo\",\"isPartOf\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg\",\"datePublished\":\"2022-07-06T14:00:42+00:00\",\"dateModified\":\"2022-10-07T22:43:54+00:00\",\"description\":\"Read on to learn more about the most fundamental Ruby on Rails examples for 2020 as you embark on your own development journey with Rails\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage\",\"url\":\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg\",\"contentUrl\":\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#website\",\"url\":\"https:\/\/www.codingdojo.com\/blog\/\",\"name\":\"Coding Dojo\",\"description\":\"Coding Bootcamp News, Career Guidance and More\",\"publisher\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.codingdojo.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#organization\",\"name\":\"Coding Dojo\",\"url\":\"https:\/\/www.codingdojo.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/Dojo-logo.png\",\"contentUrl\":\"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/Dojo-logo.png\",\"width\":287,\"height\":51,\"caption\":\"Coding Dojo\"},\"image\":{\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/CodingDojodotco\",\"https:\/\/x.com\/CodingDojoDotCo\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#\/schema\/person\/d916946be07d898fdf93ae96664934a3\",\"name\":\"Speros Misirlakis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codingdojo.com\/blog\/#\/schema\/person\/image\/9dd1789daf74a654775efe97a9930197\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f8107bac5110b20a47ac935c0f0f09e0dc560a10c9b537668e7660bc9e89358?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f8107bac5110b20a47ac935c0f0f09e0dc560a10c9b537668e7660bc9e89358?s=96&r=g\",\"caption\":\"Speros Misirlakis\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ruby on Rails Examples to Consider | Coding Dojo","description":"Read on to learn more about the most fundamental Ruby on Rails examples for 2020 as you embark on your own development journey with Rails","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples","og_locale":"en_US","og_type":"article","og_title":"Ruby on Rails Examples to Consider | Coding Dojo","og_description":"Read on to learn more about the most fundamental Ruby on Rails examples for 2020 as you embark on your own development journey with Rails","og_url":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples","og_site_name":"Coding Dojo","article_publisher":"https:\/\/www.facebook.com\/CodingDojodotco","article_published_time":"2022-07-06T14:00:42+00:00","article_modified_time":"2022-10-07T22:43:54+00:00","og_image":[{"width":600,"height":350,"url":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/BlogImg_Ruby_600x350.png","type":"image\/png"}],"author":"Speros Misirlakis","twitter_card":"summary_large_image","twitter_creator":"@CodingDojoDotCo","twitter_site":"@CodingDojoDotCo","twitter_misc":{"Written by":"Speros Misirlakis","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#article","isPartOf":{"@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples"},"author":{"name":"Speros Misirlakis","@id":"https:\/\/www.codingdojo.com\/blog\/#\/schema\/person\/d916946be07d898fdf93ae96664934a3"},"headline":"Ruby on Rails Examples to Consider for Your Developmental Journey","datePublished":"2022-07-06T14:00:42+00:00","dateModified":"2022-10-07T22:43:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples"},"wordCount":2090,"publisher":{"@id":"https:\/\/www.codingdojo.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage"},"thumbnailUrl":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg","articleSection":["All Posts"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples","url":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples","name":"Ruby on Rails Examples to Consider | Coding Dojo","isPartOf":{"@id":"https:\/\/www.codingdojo.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage"},"image":{"@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage"},"thumbnailUrl":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg","datePublished":"2022-07-06T14:00:42+00:00","dateModified":"2022-10-07T22:43:54+00:00","description":"Read on to learn more about the most fundamental Ruby on Rails examples for 2020 as you embark on your own development journey with Rails","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codingdojo.com\/blog\/ruby-on-rails-examples#primaryimage","url":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg","contentUrl":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/311.jpg"},{"@type":"WebSite","@id":"https:\/\/www.codingdojo.com\/blog\/#website","url":"https:\/\/www.codingdojo.com\/blog\/","name":"Coding Dojo","description":"Coding Bootcamp News, Career Guidance and More","publisher":{"@id":"https:\/\/www.codingdojo.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codingdojo.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codingdojo.com\/blog\/#organization","name":"Coding Dojo","url":"https:\/\/www.codingdojo.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codingdojo.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/Dojo-logo.png","contentUrl":"https:\/\/www.codingdojo.com\/blog\/wp-content\/uploads\/Dojo-logo.png","width":287,"height":51,"caption":"Coding Dojo"},"image":{"@id":"https:\/\/www.codingdojo.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CodingDojodotco","https:\/\/x.com\/CodingDojoDotCo"]},{"@type":"Person","@id":"https:\/\/www.codingdojo.com\/blog\/#\/schema\/person\/d916946be07d898fdf93ae96664934a3","name":"Speros Misirlakis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codingdojo.com\/blog\/#\/schema\/person\/image\/9dd1789daf74a654775efe97a9930197","url":"https:\/\/secure.gravatar.com\/avatar\/6f8107bac5110b20a47ac935c0f0f09e0dc560a10c9b537668e7660bc9e89358?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f8107bac5110b20a47ac935c0f0f09e0dc560a10c9b537668e7660bc9e89358?s=96&r=g","caption":"Speros Misirlakis"}}]}},"authors":[{"term_id":156,"user_id":0,"is_guest":1,"slug":"cap-speros-2015","display_name":"Speros Misirlakis","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&r=g","author_category":"","user_url":"","last_name":"","first_name":"","job_title":"","description":""}],"_links":{"self":[{"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/posts\/3501","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/users\/1367"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/comments?post=3501"}],"version-history":[{"count":0,"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/posts\/3501\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/media?parent=3501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/categories?post=3501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/tags?post=3501"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.codingdojo.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}