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

Ruby on-RailsRuby on-Rails-3

Ruby on-Rails Problem Overview


helper.method_name worked in some version of Rails... are there ways that work in both Rails 2.2.2, 2.3.5, and 3.0.1? (to use all view and helper methods)

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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

Solution 2 - Ruby on-Rails

please try to this

rails console
helper.any_method_of_helper(pass_argument)

example

helper.number_to_currency('123.45')

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnonopolarityView Question on Stackoverflow
Solution 1 - Ruby on-RailsNicolas BlancoView Answer on Stackoverflow
Solution 2 - Ruby on-Railsuser3412661View Answer on Stackoverflow