English 中文(简体)
How can I use devise helper in netzke?
原标题:

I m using Devise and Netzke gems. My rails version is 3.1.1

I want to access a devise helper (current_user) in netzke component.

But it not in model or views. It in rails_root/app/component/some_component.rb

How can I call helper method? Thanks.

There is my code....

# 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

In Views

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

<%= netzke :main_container, :class_name => "NoteGrid" %>
最佳回答

You can access the current user instance via Netzke::Core.current_user It can also be useful to access the netzke controller instance, which can be done via Netzke::Core.controller

问题回答

暂无回答




相关问题
Testing devise with shoulda

I m having some difficulties in testing devise with shoulda: 2) Error: test: handle :index logged as admin should redirect to Daily page. (Admin::DailyClosesControllerTest): NoMethodError: undefined ...

Problem with Devise authentication on Rails

I tried to use Devise 1.0.6 over Rails 2.3. I followed the installation instructions and the user can successfully sign up. However, when I use the registered user account to sign in, the password ...

Creating an admin user in Devise on Rails beta 3

Ok, I m probably going to feel quite dumb when someone answers this one with a simple thing that I m missing but... here goes: I ve got a brand new app on rails 3 beta and I m using devise for the ...

Using devise with Rails 3 beta

I m currently trying to use Devise 1.1.pre3 as authentication in my upcoming project, but I can t get it to work properly. I have done everything it says in the documentation, installed warden and ...

热门标签