Coder Social home page Coder Social logo

Problem setup with Rails about mjml-rails HOT 9 CLOSED

sighmon avatar sighmon commented on September 26, 2024
Problem setup with Rails

from mjml-rails.

Comments (9)

sighmon avatar sighmon commented on September 26, 2024

@hugogiraudel @pgoetze Oh right, in foobar_mailer.rb try this:

# ./app/mailers/foobar_mailer.rb
class FoobarMailer < ActionMailer::Base
  def baz()
    mail(to: '[email protected]', subject: 'test') do |format|
      format.text
      format.mjml
    end
  end
end

I'll add that to the README if it solves your problem.

from mjml-rails.

KittyGiraudel avatar KittyGiraudel commented on September 26, 2024

Hey, it seems to work, thanks!

Do you have any idea why a partial render does not crash but outputs nothing?

<%= render partial: 'need_link' %>

Also tried:

<%= render 'need_link' %>

Also tried:

<%= render partial: 'need_link', formats: [:mjml] %>

The partial does not print anything. :(

from mjml-rails.

KittyGiraudel avatar KittyGiraudel commented on September 26, 2024

My bad, the formats should be [:html]. I misread the docs. Thanks! :x

from mjml-rails.

sighmon avatar sighmon commented on September 26, 2024

@hugogiraudel glad it's working for you now. Feel free to make improvements. :-)

from mjml-rails.

manuelmeurer avatar manuelmeurer commented on September 26, 2024

I had the exact opposite problem as OP. 😄
When I write

mail to: '[email protected]', subject: 'test' do |format|
  format.text
  format.mjml
end

Rails can't find the template. When I just write mail to: '[email protected]', subject: 'test' it works fine. Maybe a change in a recent version? I'm on v2.2.0.

from mjml-rails.

sighmon avatar sighmon commented on September 26, 2024

@manuelmeurer that's a known bug we're trying to find an elegant solution for at the moment. @thatpixguy has an ugly hack that gets around it for now.. did you want to post that here Pix?

Just out of interest, what folder are your views in @manuelmeurer ?

from mjml-rails.

manuelmeurer avatar manuelmeurer commented on September 26, 2024

I put my views in a mailers folder, maybe that's the issue?

class ApplicationMailer < ActionMailer::Base
  def self.inherited(subclass)
    subclass.default template_path: "mailers/#{subclass.name.to_s.underscore}"
  end
end

from mjml-rails.

sighmon avatar sighmon commented on September 26, 2024

@manuelmeurer @hugogiraudel Try this and let me know how you get along:

    lookup_context.view_paths = ["test/views/template_subdir"]
    mail( to: '[email protected]', subject: 'test' ) do |format|
      format.text
      format.mjml
    end

from mjml-rails.

manuelmeurer avatar manuelmeurer commented on September 26, 2024

Well, I'm actually happy with the way it works right now (without needing the block at all). 😄

from mjml-rails.

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.