[LRUG] use application controller in rails cells
Riccardo Tacconi
rtacconi at gmail.com
Tue Feb 9 09:41:10 PST 2010
Do I have a controller instance in the cell? I have no idea. Here is a
better explanation of what I am doing:
In ApplicationController I have:
helper_method :is_admin?
and then the implementation of the method. I can use is_admin? method in
HolidayController but not in its cell.
class HolidayController < ApplicationController
layout 'categories'
before_filter :only_moderators
auto_complete_for :user, :email
in_place_edit_for :user, :total_holiday
def index
@user = User.new
@admin_dashboard = render_cell :admin_dashboard, :display, :user =>
@user
is_admin? current_user
end
So in the cell when I trie to use it:
class AdminDashboardCell < ::Cell::Base
def display
if is_admin? 3438
render :view => 'admin_display'
else
render :view => 'non_admin_display'
end
end
end
I get:
undefined method `is_admin?'
On Tue, Feb 9, 2010 at 5:30 PM, Tim Cowlishaw <tim at timcowlishaw.co.uk>wrote:
>
> On 9 Feb 2010, at 17:23, Riccardo Tacconi wrote:
>
> > I am trying to use Rails Cells. I have a is_admin? method but is not
> accessible from Cells controller (Cell::Base). Do you know how I can access
> mothods in application controller?
> >
>
> Hmm - correct me if I'm wrong, but (assuming they're public methods), you
> should be able to call them on the @controller instance variable from within
> a cell instance?
>
> Cheers,
>
> Tim
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
--
Riccardo Tacconi
Web developer at Wolseley UK
VIRTUELOGIC LIMITED (Director)
http://www.linkedin.com/in/riccardotacconi
http://riccardotacconi.blogspot.com/
http://twitter.com/rtacconi
Linux user: #400461
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20100209/25b06271/attachment-0003.html>
More information about the Chat
mailing list