【问题标题】:Creating helper in rails 3在 Rails 3 中创建助手
【发布时间】:2011-01-13 02:37:30
【问题描述】:

我正在尝试将以下狙击转换为助手:

<%= f.autocomplete_field :profissao_nome,
                autocomplete_profissao_nome_pacientes_path,
                :value => (@item.profissao.nome if @item.profissao),
                :id_element => "#paciente_profissao_id", :class => 'element text search-modal'%>
            <%= f.text_field :profissao_id, :type => "text" %>
            <%= link_to "", search_profissaos_path, :class=>"iframe", :anchorDescription => "paciente_profissao_nome", :anchorId => "paciente_profissao_id" %>

但是,我所有的尝试都失败了。即使我得到相同的 html 输出,“id_element”的行为也不起作用。

def lookup_field(object_name, method, source, options ={})

    autocomplete_field(object_name, method, source, options) + "\n" +
    text_field(object_name, "religiao_id", {:type => "text"})  + "\n" +
    link_to("", eval("search_religiaos_path"), :anchorDescription=>object_name.to_s+"_religiao_nome", :anchorId=>object_name.to_s+"_religiao_id", :class => "iframe")  end
  end

【问题讨论】:

    标签: ruby-on-rails helpers


    【解决方案1】:

    确保将表单构建器对象 f 传递给您的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      相关资源
      最近更新 更多