活动脚手架:config.link.inline = false 不起作用

发布于 2024-12-25 02:48:35 字数 2327 浏览 1 评论 0原文

使用 Rails 3.1.0 和 Active Scaffold(来自 git repo)。我的控制器具有如下所示的代码:

active_scaffold :template do |config|
  config.create.link.inline = false
  config.actions = [:list, :search, :create, :delete]
  config.columns = [
     :name, 
     :description
    ]
  config.list.sorting = { :created_at => :desc }
end

从理论上讲,这意味着活动脚手架列表顶部的“创建新”链接应该在没有数据远程调用的情况下呈现,但它仍然像这样呈现

<a href="/admin/templates/new" class="new" data-remote="true" id="as_admin__templates-new--link">Create New</a>

:还用以下内容覆盖 _action_group.html.erb ,但我已删除该文件进行测试,但它没有任何效果。这是覆盖中的代码:

<% record ||= nil
   start_level_0_tag ||= ''
   end_level_0_tag ||= ''%>
<% action_links.traverse(controller, traverse_options) do |parent, link, options| -%>
  <% if (options[:node] == :finished_traversing) -%>
    <%= "</ul>#{(options[:level] == 0 ? "</div>#{end_level_0_tag}": '</li>')}".html_safe %>
  <% elsif (options[:node] == :start_traversing) -%>
        <% html_classes = []
           html_classes << 'hover_click' if hover_via_click? %>
  <% if options[:level] == 0 %>
           <% html_classes << 'action_group' %>
     <%= "#{start_level_0_tag}<div class=\"#{html_classes.join(' ')}\" #{"onclick=\"\"" if hover_via_click?}> #{content_tag(:div, as_(parent.name), :class => (parent.name.to_s).downcase)}<ul>".html_safe %>
  <% else %>
           <% html_classes << 'top' if options[:first_action] %>
     <%= "<li #{"class=\"#{html_classes.join(' ')}\"" unless html_classes.empty?} #{"onclick=\"\"" if hover_via_click?}>#{content_tag(:div, as_(parent.name), :class => (parent.name.to_s).downcase)}<ul>".html_safe %>
  <% end %>
  <% else -%>
    <% if options[:level] == 0 %>
      <%= "#{start_level_0_tag}#{render_group_action_link(link, url_options, options, record)}#{end_level_0_tag}".html_safe %>
    <% else %>
      <%= content_tag('li', render_group_action_link(link, url_options, options, record), options[:first_action] ? {:class => 'top'}: {}) %>
    <% end %>
  <% end -%>
<% end -%>

在我尝试设置 config.create.link.inline 的任何地方都会发生这种情况。我需要寻找一些最重要的设置吗?

Using Rails 3.1.0, with Active Scaffold (from the git repo). My controllers have code that look like this:

active_scaffold :template do |config|
  config.create.link.inline = false
  config.actions = [:list, :search, :create, :delete]
  config.columns = [
     :name, 
     :description
    ]
  config.list.sorting = { :created_at => :desc }
end

Theoretically, this means that the "create new" link at the top of the active scaffold list should be rendered without a data-remote call, but it is still being rendered like that:

<a href="/admin/templates/new" class="new" data-remote="true" id="as_admin__templates-new--link">Create New</a>

We're also overriding _action_group.html.erb with the following, but I've deleted the file for testing and it has no effect. Here's the code in the override:

<% record ||= nil
   start_level_0_tag ||= ''
   end_level_0_tag ||= ''%>
<% action_links.traverse(controller, traverse_options) do |parent, link, options| -%>
  <% if (options[:node] == :finished_traversing) -%>
    <%= "</ul>#{(options[:level] == 0 ? "</div>#{end_level_0_tag}": '</li>')}".html_safe %>
  <% elsif (options[:node] == :start_traversing) -%>
        <% html_classes = []
           html_classes << 'hover_click' if hover_via_click? %>
  <% if options[:level] == 0 %>
           <% html_classes << 'action_group' %>
     <%= "#{start_level_0_tag}<div class=\"#{html_classes.join(' ')}\" #{"onclick=\"\"" if hover_via_click?}> #{content_tag(:div, as_(parent.name), :class => (parent.name.to_s).downcase)}<ul>".html_safe %>
  <% else %>
           <% html_classes << 'top' if options[:first_action] %>
     <%= "<li #{"class=\"#{html_classes.join(' ')}\"" unless html_classes.empty?} #{"onclick=\"\"" if hover_via_click?}>#{content_tag(:div, as_(parent.name), :class => (parent.name.to_s).downcase)}<ul>".html_safe %>
  <% end %>
  <% else -%>
    <% if options[:level] == 0 %>
      <%= "#{start_level_0_tag}#{render_group_action_link(link, url_options, options, record)}#{end_level_0_tag}".html_safe %>
    <% else %>
      <%= content_tag('li', render_group_action_link(link, url_options, options, record), options[:first_action] ? {:class => 'top'}: {}) %>
    <% end %>
  <% end -%>
<% end -%>

This is happening everywhere that I try to set the config.create.link.inline. Is there some overriding setting somewhere that I need to look for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半衬遮猫 2025-01-01 02:48:35

做:

config.create.link.page = true

helpers/ 中得出此结论的相关位view_helpers.rbdata_structs/action_link.rb

因为有 3 个互斥的属性(page、inline、popup),所以将其中一个设置为 false 不会影响另一个(分析控制流),只有将其中一个设置为 true 才会将其他两个设置为 false。

“阅读来源,卢克”

Do:

config.create.link.page = true

Relevant bits to reach this conclusion in helpers/view_helpers.rb and data_structures/action_link.rb.

Because there are 3 mutually exclusive properties (page, inline, popup), setting one to false does not affect the other (analyze the control flow), only setting one to true sets the other two to false.

"Read the source, Luke"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文