All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Date Formatting I | |
| '%Y' #Year with century (e.g. 2015, 1995, etc) | |
| '%m' #Month of the year, zero-padded (01..12) | |
| '%B' #The full month name (e.g. January) | |
| '%b' #The abbreviated month name (e.g. Jan) | |
| '%d' #Day of the month, zero-padded (01..31) | |
| '%j' #Day of the year (001..366) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #dwarf.rb | |
| class Dwarf | |
| include Comparable | |
| def initialize(name, age, beard_strength) | |
| @name = name | |
| @age = age | |
| @beard_strength = beard_strength | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RunStrategies | |
| class RunStrategyInterface | |
| def self.run(name) | |
| raise "Run method has not been implemented!" | |
| end | |
| end | |
| class Jog < RunStrategyInterface | |
| def self.run(name) | |
| puts "#{name} is now jogging at a comfortable pace." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT DATA_TYPE | |
| FROM INFORMATION_SCHEMA.COLUMNS | |
| WHERE | |
| TABLE_NAME = 'yourTableName' | |
| COLUMN_NAME = 'yourColumnName' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DatabaseHelper | |
| def self.select name, *args, &blk | |
| execute "select", name, *args, &blk | |
| end | |
| def self.call name, *args, &blk | |
| execute "call", name, *args, &blk | |
| end | |
| def self.execute via, name, *args, &blk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| # This files shows some possible implementations of the Singleton pattern | |
| # in Ruby. I'm not a huge fan of the Singleton pattern, but it's nice | |
| # in some cases. In this file I'm going to implement a simple logger. | |
| # | |
| ## | |
| # The first implementation that can come to our minds is to create a class | |
| # that holds an instance as a class variable that can be accessed through |