Doesn't update without server restart #6

turadg opened this Issue Sep 5, 2011 · 35 comments


None yet

turadg commented Sep 5, 2011

When I'm in :development, most of my classes update in the runtime as I edit their code. But when I edit my Preview class, say to add a new preview method, nothing changes in the browser.

Same for me

Same here

sohara commented Nov 1, 2011

Ditto. Would be useful if mail_view's classes/modules weren't cached in non-production environments.

Edit: by that I mean classes that inherit from MailView.

halida commented Nov 28, 2011

same here...

sethbro commented Nov 29, 2011

Same here. Kind of defeats the purpose when you're attempting to preview changes during development.


jeremy commented Mar 30, 2012

This is a hassle. Patches welcome to make the middleware respect dev-mode reloading.

I found this to be frustrating also, but (I think) I'm successfully working around it by adding this to my development.rb:
config.action_view.cache_template_loading = false

When I do that, no server restarts are needed. Of course, I don't want that setting on all the time, so I only use it when testing my email templates. Hope that helps!

Agree. Absolutely useless without this feature. Somebody let me know if they decide to fork a fix and I'll use that, otherwise, might be tempted to create one myself.


dhh commented May 17, 2012

@damien-roche, you go, girl!

@dhh, ok, not absolutely useless. But 9 months, and still no fix? Is this project abandoned? I fear you may know the inner workings of Rails a little more intimately than me ;)

@adilwali, This solution worked for me thanks!!!

While I'm on rails 3.2, the way @adilwali suggested, it doesn't work for me.
@jwarzech Which version of rails did you use?

@millisami I am using rails 3.2.9

@jwarzech Ok, then I suppose I'll to test it out on 3.2.9 Thanks.

@millisami I have tested it on Rails 3.2.9
It works
What is your result?

BTW is it possible to make it reload the MailPreview class without restart?

@PikachuEXE Did it work for you without adding the config.action_view.cache_template_loading = false in development.rb or just installing the gem only?

@millisami Oh removing that config still works for template

But still not the class (MailPreview or something)

So this issue is still valid

So then I guess have to wait on this issue to be fixed or is there any other forks that solved this?

Is ActionMailer classes supposed to be eager loaded in app and rspec? I forgot

And I cannot find any code related to eager loading...

Still not fixed, what's the real problem? Should I try to investigate and fix it?

The problem is that the actions of any subclass of MailView seem to be preloaded and cached
even on development (with cache config set to false of course)
So that when you try to add a new action, it does not show up on refresh of index page (e.g./mail_view)

@pickachuexe It can be caused by class constant passed from routes.rb?

I have no idea how mount work
So maybe

@pickachuexe ok, it's on my todo list now. I'll check later. Same symptoms rails_admin gem has (but it's not a bug, it's kind of expected behavior).

Great to hear that! Thanks!

P.S. You don't need to mention my name every time
I am watching this thread

That's OK, since I'm twitter addict 👍

Here's my cheesy workaround to this issue. Basically, I just route all the requests to the mail view indirectly from a controller. This allows Rails to reload the mail view class.

# routes
match '/mailers/:mailer(/:name)', :to => "mailers#show"

# controller
class MailersController < ApplicationController
  def show
      'PATH_INFO'   => params[:name].to_s,
      'SCRIPT_NAME' => url_for(:name => nil)

    mailer = params[:mailer].classify.constantize
    status, headers, body =
    render :text => body.join('').html_safe

# a mail view
class PreviewMailer < MailView
  def some_notification
    # do stuff

Then hit /mailers/preview_mailer to see the list of actions.

@scharfie It's working! Thanks!
Wonder if this can be included in the gem to solve this bug...

After using this workaround
I got this bug: Mange/roadie#52
It happens often already before using the workaround

@scharfie - nice thanks. Does this break .txt email handling, or is that my own slim templates / routing issue?

Make sure it's development only or that's a pretty big security hole.

In case anyone runs into my problem of it not working with text emails, commenting out the format.html {} in your mailer block will render the text mail instead (since it's the only one then).

Fixed in rails/rails#10685 🎉

trevorturk closed this Jun 7, 2013

@trevorturk Wait, is this gem only being maintained as part of the Rails core now?

@thenickcox, this particular issue turned out to be caused by a Rails bug and was fixed 7 months ago.

I'm not sure about the maintenance plan for this gem. I'd imagine it'll get some fixes but that the bulk of the work will be directed toward the new "inspired by mail_view" feature in Rails (rails/rails#13332)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment