fgrehm/letter_opener_web

Usage with Rails app installed in a sub-URI

MischaTheEvil opened this issue · 2 comments

I recently used the letter_opener_web gem on a Bitnami Redmine stack (which has the Rails app installed in a sub-URI [using Rails' config.action_controller.relative_url_root]) and I had to do some additional configuration (modification) to get the whole thing to run. As this might be useful to others too, I decided to post this issue.

I installed the gem, added the route to the engine and browsed to the set URL. The page opened without errors and the already received mails were picked-up and shown correctly.
However, three things didn't work:

  1. 'View plain text version' links resulted in a 404 within the frame
  2. Individual mail's delete buttons resulted in a 404 within the document, but the mails actually got deleted
  3. 'Clear' button resulted in a 404 within the document, but all mails actually got deleted

All these 404's showed me letter_opener_web URL's missing the sub-URI part of my Rails app. After some investigation I found out that I had to manually add the sub-URI to the routes of letter_opener_web. So I added Rails.application.routes.default_url_options[:script_name] = '/sub-URI' to LetterOpenerWeb::Engine.routes (by modifying https://github.com/fgrehm/letter_opener_web/blob/master/config/routes.rb), restarted the whole stack and tried it again. All earlier issues got resolved.

Environment:

  • Bitnami Redmine stack: 3.3.1-0-windows
  • Rails: 4.2.7.1
  • letter_opener: 1.4.1
  • letter_opener_web: 1.3.0

Hey @MischaTheEvil! Sorry for the long delay here.

Is this something you're still interested on? I personally haven't used Redmine (or any apps that are mounted on sub-URIs) in a long time.

Also curious what are @pseudomuto thoughts here. I've been missing in action for a while and he's the one that has been pushing the project forward while I was away 😅

Hey @MischaTheEvil! I'm getting ready to cut a 2.0 release in #113 and this has become stale.

I'm going to close it for now, feel free to open a new issue if you or anyone else think this is still valuable!