Creating Custom Rails Console MethodsTired of typing the same commands in console every time you The straw that breaks my back is “Character.find_by_name(‘super_long_nameski’)” Using method missing, I’m going to make typing super_long_nameski One way to do this is to add methods to your .irbrc or .railsrc file. However, knowing that everyone in my project will use this code, I’ve All code in the directory /config/initializers is run when rails starts, so /config/initializers/object.rb
Yes, we’re adding a method to all objects; however, If method_missing finds a character, it returns it. If not or if the command
Finally! |
|