Coder Social home page Coder Social logo

Comments (39)

atipugin avatar atipugin commented on August 20, 2024

Same for me

from mail_view.

alejandrodumas avatar alejandrodumas commented on August 20, 2024

Same here

from mail_view.

sohara avatar sohara commented on August 20, 2024

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.

from mail_view.

halida avatar halida commented on August 20, 2024

same here...

from mail_view.

sethbro avatar sethbro commented on August 20, 2024

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

from mail_view.

jeremy avatar jeremy commented on August 20, 2024

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

from mail_view.

adilwali avatar adilwali commented on August 20, 2024

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!

from mail_view.

damien-roche avatar damien-roche commented on August 20, 2024

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.

from mail_view.

dhh avatar dhh commented on August 20, 2024

@damien-roche, you go, girl!

from mail_view.

damien-roche avatar damien-roche commented on August 20, 2024

@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 ;)

from mail_view.

danspencer avatar danspencer commented on August 20, 2024

+1

from mail_view.

jwarzech avatar jwarzech commented on August 20, 2024

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

from mail_view.

millisami avatar millisami commented on August 20, 2024

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?

from mail_view.

jwarzech avatar jwarzech commented on August 20, 2024

@millisami I am using rails 3.2.9

from mail_view.

millisami avatar millisami commented on August 20, 2024

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

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

@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?

from mail_view.

millisami avatar millisami commented on August 20, 2024

@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?

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

@millisami Oh removing that config still works for template

But still not the class (MailPreview or something)

So this issue is still valid

from mail_view.

millisami avatar millisami commented on August 20, 2024

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

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

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

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

from mail_view.

killthekitten avatar killthekitten commented on August 20, 2024

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

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

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)

from mail_view.

killthekitten avatar killthekitten commented on August 20, 2024

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

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

I have no idea how mount work
So maybe

from mail_view.

killthekitten avatar killthekitten commented on August 20, 2024

@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).

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

Great to hear that! Thanks!

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

from mail_view.

killthekitten avatar killthekitten commented on August 20, 2024

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

from mail_view.

scharfie avatar scharfie commented on August 20, 2024

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
    request.env.merge!(
      'PATH_INFO'   => params[:name].to_s,
      'SCRIPT_NAME' => url_for(:name => nil)
    )

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

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

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

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

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

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

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

from mail_view.

inspire22 avatar inspire22 commented on August 20, 2024

@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.

from mail_view.

inspire22 avatar inspire22 commented on August 20, 2024

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).

from mail_view.

trevorturk avatar trevorturk commented on August 20, 2024

Fixed in rails/rails#10685 🎉

from mail_view.

thenickcox avatar thenickcox commented on August 20, 2024

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

from mail_view.

trevorturk avatar trevorturk commented on August 20, 2024

@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)

from mail_view.

mayuresh-srivastava avatar mayuresh-srivastava commented on August 20, 2024

How to solve this issue for Rails 5 (Rails 5.1.6 specifically)?
Because solution provided by @adilwali i.e. config.action_view.cache_template_loading = false not working.

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

There is email preview in rails now
::ActionMailer::Preview
Try to use that

from mail_view.

mayuresh-srivastava avatar mayuresh-srivastava commented on August 20, 2024

@PikachuEXE Yeah I am using ActionMailer::Preview only.

from mail_view.

PikachuEXE avatar PikachuEXE commented on August 20, 2024

Then any related issue should be reported to rails repo

from mail_view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.