-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to cookies in a widget #149
Comments
You can do |
@apotonick I have an example where I need to set a cookie for an action that happens on a widget, how would you work around calling parent_controller.send(:cookies) ? I have encapsulated it on a method in the parent controller. so I dont directly call cookies inside my widget, like class SignupWidget < Apotomo::Widget
responds_to_event :subscribe
def display
end
def subscribe
parent_controller.set_cookie(args)
end
end
def ApplicationController < ActionController::Base
def set_cookie(args)
cookies[:whatever] = args[:whatever]
end
end But still not sure this is the correct solution! if you have any other options I would like to hear about it! |
I personally don't have any solution for that as I think a widget should not know about HTTP cookies. But I like how you introduce a certain level of encapsulation, though. Do you need this in one place, only, or is this a common requirement in your app? Anyways, I think what you do is correct! 😁 |
Or do you still think that's a bad idea? I have seen I am not the only one asking for this, as I found more posts about this problem/need. |
The wiring of AJAX --> controller --> widget and back is one thing in Apotomo. The other main concept is that of a widget, and a widget in Apotomo is not supposed to know anything about HTTP. This is what makes it different to Rails where every "MVC" "component" knows about every other layer. Apotomo and Cells try to get away from the concept of an all-mighty "controller". Maybe it's easier to understand if you think of a widget in other environments: imagine an Apotomo widget being part of a native GUI application. There is no such thing as "cookies" in a native app, and that's where we want to get with Apotomo. I guess the dependency to |
Hello!
I've found a similar topic on google groups, it's a bit old and i'm not sure if google groups is an official way for asking questions but so i'll ask again here.
I'm trying to use a
cookies
variable in my widget view and it's impossible due toUnknown method 'cookies'
exception. In the previously mentioned topic, Nick suggests to use the following code in my widget:However, it's not working. Right now, i'm getting
private method 'cookies' called for #<VideosController:0x0000010ab7fdf8>
Have you any idea how can i deal with that?
Thanks in advance.
The text was updated successfully, but these errors were encountered: