首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在netzke中使用devise helper?

如何在netzke中使用devise helper?
EN

Stack Overflow用户
提问于 2011-11-08 18:37:47
回答 1查看 712关注 0票数 0

我使用的是Devise和Netzke gem。我的rails版本是3.1.1

我想访问netzke组件中的devise helper (current_user)。

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

如何调用helper方法?谢谢。

这是我的代码..。

代码语言:javascript
复制
# 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

在视图中

代码语言:javascript
复制
# app/views/main/index.html.erb

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

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-08 19:34:24

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8049111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档