Redmine:高级路线图插件Observe_field错误

时间:2013-06-09 14:50:42

标签: ruby-on-rails redmine-plugins

我在redmine项目上安装了Advanced Roadmap插件。 安装后,如果我尝试创建新的里程碑,则会抛出以下错误:

  ActionView::Template::Error (undefined method `observe_field' for # 


The form partial is as follows :

<%= error_messages_for 'milestone' %> <div class="box"> <p><%= f.text_field :name, :size => 60, :required => true %></p> <p><%= f.text_field :description, :size => 60 %></p> <p><%= f.text_field :effective_date, :size => 10 %><%= calendar_for('milestone_effective_date') %></p> <p> <select id="project_selector"> <% @projects.each do |project| %> <option<%= (project == @project) ? " selected" : "" %> id="<%= project.id %>"><%= h(project.name) %></option> <% end %> </select> <% javascript_tag :defer => "defer" do %> function project_changed() { object = window.document.getElementById("project_selector"); if (object) { if (object.selectedIndex != -1) { project_id = object.options[object.selectedIndex].id; <% @projects.each do |project| %> project_div = window.document.getElementById("project_<%= project.id %>_versions"); if (project_div) { project_div.style.display = "none"; project_div.style.visibility = "hidden"; } <% end %> project_div = window.document.getElementById("project_" + project_id + "_versions"); if (project_div) { project_div.style.display = ""; project_div.style.visibility = ""; } } } } jQuery(function($) { $(\"#project_selector\").change(project_change); }) <% end %> </p> <% @projects.each do |project| %> <div id="project_<%= project.id %>_versions"<%= (@project == project) ? "" : "style=\"display: none; visibility: hidden;\"" %>> <table class="list"> <thead> <th><%= l(:field_version) %></th> <th><%= l(:field_effective_date) %></th> <th><%= l(:field_description) %></th> <th><%= l(:label_milestone_plural) %></th> </thead> <% project.versions.sort.each do |version| %> <tr class="<%= cycle("odd", "even") %>"> <td> <%= check_box_tag "versions[]", version.id, @milestone.versions?(version) %> <%= link_to(h(version.name), :controller => :versions, :action => :show, :id => version) %> </td> <td align="center"><%= version.effective_date %></td> <td><%= version.description %></td> <td align="center"><%= version.milestones.collect {|m| link_to(h(m.name), :controller => :milestones, :action => :show, :id => m.id) }.join(", ").html_safe %></td> <tr> <% end %> </table> </div> <% end %> </div>

我们应该如何改变他观察现场问题,因为它已被弃用。任何帮助将不胜感激。

我正在使用

  • ruby 1.9.3 -version
  • rails 3.2.13
  • redmine 2.x

1 个答案:

答案 0 :(得分:0)

经过一番搜索后,我找到了上述问题的解决方案。

显然,在rails 3中已弃用observe_field方法。
因此,为了解决这个问题,我们需要删除observe_field辅助方法,并在视图模板的javascript_tag中添加一个javascript代码,如下所示:

<% javascript_tag :defer => "defer" do %>
  function project_changed()
  {
    object = window.document.getElementById("project_selector");
    if (object)
    {
      if (object.selectedIndex != -1)
      {
        project_id = object.options[object.selectedIndex].id;
        <% @projects.each do |project| %>
          project_div = window.document.getElementById("project_<%= project.id %>_versions");
          if (project_div)
          {
            project_div.style.display = "none";
            project_div.style.visibility = "hidden";
          }
        <% end %>
        project_div = window.document.getElementById("project_" + project_id + "_versions");
        if (project_div)
        {
          project_div.style.display = "";
          project_div.style.visibility = "";
        }
      }
    }
  }
  jQuery(function($)
  {
    $(\"#project_selector\").change(project_change);
  })
<% end %>

究竟做了什么只是我们删除了辅助方法并添加了一个小的jquery代码。

  jQuery(function($)
  {
    $(\"#project_selector\").change(project_change);
  })