Tag: helpers

帮助者“fields_for”无法正常工作

我正在使用嵌套属性,但我的视图中未加载字段。 有人知道我错过了什么吗? Rails 3.1,Ruby 1.9.2 型号1: class Traditions::Material :destroy validates_presence_of :title accepts_nested_attributes_for :material_asset end 型号2: class Traditions::MaterialAsset < ActiveRecord::Base belongs_to :material has_attached_file :asset validates_attachment_presence :asset end 查看(HAML): = form_for @material, :html => {:class => ‘form’, :multipart => true} do |f| = errors_for @material .field = f.label :title = f.text_field :title .field = f.label :description = […]

如何在带有Rails / ERB的select_tag中添加link_to?

我的index.html.erb中有以下代码 我在哪里可以在该块中添加link_to帮助器? 我可以为select_tag添加link_to吗? 所需的link_to将转到’/ Teamleader / ID_OF_OPTION_PICKED’ 更新: 更清楚; 当用户从select标签中选择一个选项时,我想将页面重定向到所需的链接(来自link_to)。

Rails 3.1:在客户端应用程序中公开引擎助手的更好方法

我找到了一些文章来解决引擎中的助手问题,这些问题不适用于消费(父)应用程序。 为了确保我们都在同一页上,让我们说我们有这个: module MyEngine module ImportantHelper def some_important_helper …do something important… end end end 如果您查看“隔离引擎的助手”(L293)中的rails引擎文档,它会说: # Sometimes you may want to isolate engine, but use helpers that are defined for it. # If you want to share just a few specific helpers you can add them to application’s # helpers in ApplicationController: # # class […]

如何修改Rails datetime_select帮助器的输入类型?

我在我的一个表单中使用Rails helper datetime_select 。 我目前要求将day , year , hour和minute的下拉列表更改为带validation的文本框。 有没有办法可以指定我想要这些字段的文本框? 或者可能是一个不同的助手,可以满足我的需求? 这是我的用法: datetime_select(:campaign, :start_date, :order => [:day, :month, :year, :hour, :minute])