In Rails, supposing that the file is already loaded, how it is possible to call my_method from this example from console?
# some_file.rb
class MyClass < ApplicationController::Base
def my_method(args)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Another, very simple way to do this is to use an instance of
ApplicationControlleritself.Then in the console, you can do the following:
This will output the following:
This, of course, has the restriction of not having access to everything a normal request would, such as the
requestobject itself. If you need this, as the Patrick Klingemann suggested, you could use the debugger… I personally recommend using Pry:This is likely much too late for you, but hopefully it will help someone in the future.