Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use all view and helper methods inside of Rails console for Rails 2.x and 3.x? [duplicate]

People also ask

Can we use helper method in controller rails?

It's possible, although not very common, to use helper methods from controller actions. Before Rails 5, you had to include the helper module. In newer versions, you can use helpers in your controller with the helpers (plural) object.

How do you use the helper method in Ruby on Rails?

A Helper method is used to perform a particular repetitive task common across multiple classes. This keeps us from repeating the same piece of code in different classes again and again. And then in the view code, you call the helper method and pass it to the user as an argument.


You can also try :

YourController.helpers.my_helper

for example :

> ApplicationController.helpers.content_tag(:div, "test")
=> "<div>test</div>" 

This works with Rails 2, 3 and 4.1


please try to this

rails console
helper.any_method_of_helper(pass_argument)

example

helper.number_to_currency('123.45')