24

Вопрос по ruby-on-rails-3, ruby-on-rails – undefined

У меня небольшая организационная проблема, в моем приложении у меня есть 3 почтовика User_mailer, prduct_mailer, some_other_mailer, и все они хранят свои представления в app / views / user_mailer ...

Я хочу иметь подкаталог в / app / views / с именем mailers и поместить все в папки user_mailer, product_mailer и some_other_mailer.

Спасибо,

  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceededappend_view_pathError: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • default template_path: "mailers/#{self.name.underscore}"Error: User Rate Limit Exceeded/app/views/mailers/user_mailer/

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceededrubydoc.info/docs/rails/ActionView/ViewPaths/…

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit ExceededApplicationMailerError: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • prepend_view_pathError: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • append_view_path Rails.root.join('app', 'views', 'mailers')

    от
5 ответов
  • 12

    Error: User Rate Limit Exceeded

    class UserMailer < ActionMailer::Base
      ...
      append_view_path("#{Rails.root}/app/views/mailers")
      ...
    end 
    

  • 19

    Error: User Rate Limit Exceeded

    ApplicationMailer

    # app/mailers/application_mailer.rb
    class ApplicationMailer < ActionMailer::Base
      append_view_path Rails.root.join('app', 'views', 'mailers')
      default from: "Whatever HQ <[email protected]>"
    end
    
    # app/mailers/user_mailer.rb
    class UserMailer < ApplicationMailer
      def say_hi(user)
        # ...
      end
    end
    
    # app/views/mailers/user_mailer/say_hi.html.erb
    <b>Hi @user.name!</b>
    

    ApplicationController < ActionController::Base).

  • 9

    Error: User Rate Limit Exceeded

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

  • 4

    Error: User Rate Limit Exceeded

    class UserMailer < ActionMailer::Base
      default :from => "[email protected]"
    
      def whatever_email(user)
        @user = user
        @url  = "http://whatever.com"
        mail(:to => user.email,
             :subject => "Welcome to Whatever",
             :template_path => '**your_path**',
             )
      end
    end
    

  • 21

    Error: User Rate Limit Exceeded

    class UserMailer < ActionMailer::Base
      default :from => "[email protected]"
      default :template_path => '**your_path**'
    
      def whatever_email(user)
        @user = user
        @url  = "http://whatever.com"
        mail(:to => user.email,
             :subject => "Welcome to Whatever",
             )
      end
    end