问题标签 [actionviewhelper]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
11128 浏览

ruby - 人性化的Rails问题

我正在尝试将作为哈希键的符号人性化

c.each_key{ |f| humanize(f.to_s)}

但由于某种原因,我收到这样的错误

ActionView::Template::Error (undefined method 'humanize' for #<#<Class:0xb5b77a4>:0xb5b6598>)

知道这里出了什么问题吗?

0 投票
1 回答
667 浏览

zend-framework - 未使用自定义视图助手找到插件

我需要一些自定义视图助手的帮助。

我的文件夹结构是这样的:

如果我去localhost/smjestaj我得到这个错误:

消息:在注册表中找不到名为“LoadSkin”的插件;使用的路径: Smjestaj_View_Helper_: /Users/davs/Zend/workspaces/DefaultWorkspace7/1/application/modules/smjestaj/views/helpers/
ZendX_JQuery_View_Helper_: ZendX/JQuery/View/Helper/
Zend_View_Helper_: Zend/View/Helper/

我试图在 application.ini 中注册我的助手,但没有运气。

如果我将文件夹复制view->helpers->LoadSkin.php到可以工作的模块 smjestaj 中,但我认为这不是正确的方法。

0 投票
2 回答
2210 浏览

ruby-on-rails - Rails:视图:content_tag 助手

我有一个控制器,它在渲染视图并输出错误之前执行以下行。

我想很好地格式化这个。为此,我写了一个看起来像这样的助手

在我看来,我呼吁:

当我尝试运行它时,网页会呈现 show_flash 的全文,包括 div 标签、尖括号和所有内容。当我检查元素(使用 Firefox 或 Chrome)时,它会显示用双引号括起来的文本。

然后我尝试在帮助程序中更改一行,如下所示:

即我只会捕获最后一个内容标签(错误)而不是两者。

在第二种情况下,Web 浏览器使用我的“错误”类的 CSS 规则正确格式化了 div 标签。我没有看到浏览器中打印出任何 div 标签。

为什么连接两个 content_tag 元素会导致我如此悲痛?

我很感激你能给我的任何帮助。

0 投票
1 回答
21602 浏览

ruby-on-rails - 如何向 Rails 的部分渲染查找添加视图路径?

我想要以下目录结构:

在我看来,我会打电话给

所以基本上,我如何告诉 Rails 在它引发它缺少模板错误之前检查 /app2/users 目录然后是共享目录?

更新


我解决了这个问题(正如 Senthil 所建议的,使用File.exist?

这是我的解决方案 - 欢迎提供反馈和建议

0 投票
1 回答
3577 浏览

ruby-on-rails-3 - Rails - 如何在控制器中获取单个图像资产的 URL?

我尝试过包含ActionView::Helpers::AssetTagHelper然后使用该image_path()方法,但它让我感到悲伤:

我可能缺少一些简单的东西。有任何想法吗?

0 投票
1 回答
865 浏览

php - Zend 动作助手重定向器

如何在模型中重定向或不在控制器中重定向?使用标准的 zend 重定向器助手

0 投票
4 回答
3871 浏览

ruby-on-rails - Rails - Date time select in specified time zone

I'm working with an app for a concert tour website, where all times (announcement times, on-sale start times, and event start times) are local to each particular venue's time zone. I take the user entered date/time where applicable and run a before_filter to set the appropriate time zone so that everything is stored in the database in UTC. For the 'new' form and for displaying the times in index and show actions, no problem at all. When the data is brought back out of the database and into a view, I use in_time_zone to adjust per the particular venue.

The only issue is on the edit form. The date/time select is showing the data in UTC. When I'm working on the site, I mentally adjust, but for others it's confusing. I'd like to do something along the lines of:

<%= f.datetime_select :start_datetime.in_time_zone(@event.time_zone) %>

Or, in the controller:

Then simply, <%= f.datetime_select :start_datetime %>.

Unfortunately, I haven't found the right way to do this. Do you have any ideas worth giving a shot?

Thank you very much.

0 投票
1 回答
187 浏览

ruby-on-rails - Rails collection_select 提示出现在初始页面加载时,而不是此后。有什么修复吗?

导轨 2.3.11。

我有一个这样的搜索表格...

当页面加载时,第一个标签为“-- Select --”(并且有value='')的选项会按预期出现。

我从该菜单中选择一个选项并提交表单。页面重新加载搜索结果。“-- 选择--”选项不再出现在菜单中。

这是一个问题,因为用户可能想要清除该菜单——将其恢复为“-- Select--”。

有什么方法可以提示在表单提交中生存吗?

(我使用的是 Haml,而不是 Erb,但你明白了。)

0 投票
1 回答
1068 浏览

ruby-on-rails - 如何在 rails 3 的邮件程序中使用表单助手?

我正在尝试为用户创建一封邮件,其中包含一个简单的 html 表单。为此,我按照http://edgeguides.rubyonrails.org/action_mailer_basics.html#example-action-mailer-configuration教程中的建议使用 Rails 3 中的 ActionMailer

我无法在邮件程序 erb 文件中使用诸如 form_tag 之类的 ActionView 助手。如何在 erb 文件中访问它们。

我的 user.html.erb 文件有这样的代码:

我收到此错误:

0 投票
2 回答
339 浏览

zend-framework - 在 Kohana 中查看助手

我正在尝试找出一种方法来执行以下操作:

我想做一个动作,它将通过 ajax 加载,并且在页面重新加载时它也是页面的内部部分。

ZEND通过使用View Helper在框架中知道这一点,但不知道该怎么做Kohana

我是Kohana的新手。

编辑: 我正在尝试做的示例http://www.espncricinfo.com/west-indies-v-india-2011/engine/current/match/489228.html?CMP=chrome

在上面的网页中,当整个网页被加载时,实时计分板也被加载。但是当你点击“刷新记分牌”按钮时,只有实时记分牌会通过 ajax 被替换。

我想创建一个动作说action_scoreboard,它将用于带来记分牌数据。并action_index加载整个页面,但在action_index我需要调用的视图中action_scoreboard

谢谢