Closed alexbrinkman closed 7 years ago
@alexbrinkman I've had a quick look in to this. Stumped again. I can't think of any reason why the dragonfly datastore would make a difference. And most of our sites use the s3 datastore too and we're not seeing this problem.
The error seems to suggest that the new PushType::MediaUrlHelper
is not available in the PushType::Admin::AssetsController
for some reason. Maybe we need to be explicitly including the helper module. I'm guessing from your logs you're on rails 4.2.x - is that right? If so, maybe there's some differences to how helpers are included between 4.2.x and 5.0.0.
In your application config, have you set config.action_controller.include_all_helpers = false
anywhere?
Yes, we are on Rails 4.2.7. I have not set config.action_controller.include_all_helpers
anywhere. If I open the console and run Rails.application.config.action_controller.include_all_helpers
, I get nil.
@aaronrussell I've been trying to dig into this issue a bit more. I think you're right that being able to call a helper right from a controller is new in Rails 5, and that it doesn't work in Rails 4. I added include PushType::MediaUrlHelper
and also had to include ActionView::Helpers::AssetUrlHelper
to the AssetsController and it works, but I don't think that's the actual real solution. Ideas?
Also, I think I was wrong that using :file for the dragonfly_datastore made any difference. I can't get it to work either way now. Sorry, I think that information was misleading.
@alexbrinkman I've just released a new version - 0.10.1 - which I hope resolves this issue.
This is a bit of a weird one. PushType has been accessing the helpers in the controllers via the view_context
method which has been around since Rails 3. I tried to recreate the issue with Rails 4.2.7 but it was working fine. Looking in to it I think calling view_context
instantiates a new view context every time so you don't actually get the same context your views are using. I have no idea why that meant it wasn't working for you but it feels like it's perhaps an unreliable way of using helpers in a controller. So have opted for a more explicit "including" of helpers modules where needed.
Thanks, that seems to have fixed the issue! I like the removal of the delay too, that's certainly noticeable.
I'm trying to point my media library to s3 and I run into an error when trying to insert an image into a node. The UI shows a message: "Something went wrong. Please try again." The actual file does end up in my media library, but not in the node that I'm trying to insert it into. I don't have the same issue when using :file for the dragonfly datastore.
Here is the error from the log: