如何在 Rails 控制台内为 Rails 2.x 和 3.x 使用所有视图和辅助方法? [英] How to use all view and helper methods inside of Rails console for Rails 2.x and 3.x?

查看:26
本文介绍了如何在 Rails 控制台内为 Rails 2.x 和 3.x 使用所有视图和辅助方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

helper.method_name 在某些版本的 Rails 中工作......是否有在 Rails 2.2.2、2.3.5 和 3.0.1 中工作的方法?(使用所有视图和辅助方法)

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)

推荐答案

你也可以试试:

YourController.helpers.my_helper

例如:

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

这适用于 Rails 2、3 和 4.1

This works with Rails 2, 3 and 4.1

这篇关于如何在 Rails 控制台内为 Rails 2.x 和 3.x 使用所有视图和辅助方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆