At the time of development of a module or functionality we always curious that the code we wrote will work perfectly or not until and unless we run that in a browser. so rails provide us a way where we can test the functions via a console. By running rails console you will enter into an interactive environment where you can access the code of your rails application. and the environment is really helpful. It is commonly used where we have to see the data without logging to the database. you can also specify the rails environment like
rails c RAILS_ENV=production
This is useful to troubleshoot things on the spot.
Controller functions to be called like this:
class DummyController < ApplicationController
def test
puts 'Hi there'
end
end
1) controller = DummyController.new <RETURN>
2) controller.test <RETURN>
View Helpers functions to be called like this:
include EventsHelper
EventsHelper.display_event_image(238)
or
EventsController.helpers.display_event_image(238)
0 Comment(s)