0

我正在使用 Devise 和 Netzke 宝石。我的导轨版本是 3.1.1

我想访问 netzke 组件中的设计助手(current_user)。

但它不在模型或视图中。它在 rails_root/app/component/some_component.rb

如何调用辅助方法?谢谢。

有我的代码....

# app/component/note_grid.rb
class NoteGrid < Netzke::Basepack::GridPanel
  js_property :title, "Note"

  model "Note"

  def configuration
    super.merge(
      # I want to call helper method here.
      :strong_default_attrs => {:user_id => current_user.id},  
      :columns => [{:name => :updated_at, :header => "Date - Time", :format => "d M Y - h:i A",  :width => 200}, :description],
      :add_form_config => {:items => [:description]},
      :edit_form_config => {:items => [:description]}
    )
  end
end

在视图中

# app/views/main/index.html.erb

<%= netzke :main_container, :class_name => "NoteGrid" %>
4

1 回答 1

1

您可以通过访问当前用户实例Netzke::Core.current_user 访问 netzke 控制器实例也很有用,这可以通过Netzke::Core.controller

于 2011-11-08T11:34:24.363 回答