How to create a custom method for the rails console?

前端 未结 3 1932
情话喂你
情话喂你 2021-01-06 04:54

When I\'m using the Rails console in Ubuntu for a long session I define the clear method:

def clear; system \'clear\' end

So when m

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-06 05:14

    Just put it in the ~/.irbrc file. It gets loaded every time you run irb or rails console. The Rails console is just irb with your Rails application environment loaded.

    Find more infos about irb here: http://ruby-doc.com/docs/ProgrammingRuby/html/irb.html#S2

提交回复
热议问题