Access to cookies from widget

121 views
Skip to first unread message

atmorell

unread,
Mar 22, 2011, 8:47:28 AM3/22/11
to Cells and Apotomo
Hey,

How do I access the cookie object from a Apotomo widget?

cookies
NameError: undefined local variable or method `cookies' for Node ID:
art_form Parent: root Children: 0 Total Nodes:
1:ArtWidgets::FormWidget

Works fine if I do it from a normal rails 3 view.



Best regards.
Asbjørn Morell

Nick Sutterer

unread,
Mar 22, 2011, 1:04:23 PM3/22/11
to cells-an...@googlegroups.com
Try to delegate #cookies to the parent_controller and define it as a
helper method. Really not sure why you can access a cookie object in a
view at all. Anyway, if you need it:

class MorellusWallaceWidget < Apotomo::Widget
delegate :cookies, :to => :parent_controller
helper_method :cookies


Nick

>
>
> Best regards.
> Asbjørn Morell

atmorell

unread,
Mar 22, 2011, 1:47:15 PM3/22/11
to Cells and Apotomo
Well now the method is responding, but it is empty

art_widgets/form_widget.rb:11
(rdb:3) irb
irb(Node ID: art_form Parent: root Children: 0 Total Nodes: 1):001:0>
cookies
=> {}

Returns a cookie string if I call it from the rails controller.. Any
ideas?


On Mar 22, 6:04 pm, Nick Sutterer <apoton...@gmail.com> wrote:

atmorell

unread,
Mar 22, 2011, 3:24:23 PM3/22/11
to Cells and Apotomo
Doh! was getting empty cookies because I had not saved anything in my
session before I started my debugger.

Thanks

mbajur

unread,
Mar 28, 2014, 6:16:51 AM3/28/14
to cells-an...@googlegroups.com
I've tried your solution @Nick but right now, i'm getting the error:

ActionView::Template::Error (private method `cookies' called for #<VideosController:0x0000010b707720>)

Any idea what's wrong? Thanks in advance for any clue

andre....@gmail.com

unread,
Nov 24, 2014, 8:57:00 AM11/24/14
to cells-an...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages