开发者

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

This question already has answers here: How can I call controller/view helper methods from the console in Ruby on Rails? 开发者_如何学C (14 answers) Closed 7 years ago.

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)


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')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜