weixin_33711647 2017-10-23 21:51 采纳率: 0%
浏览 61

Rails 5操作邮件错误

I'm having issues with rails action mailer. When I click on my subscribe button I keep getting the same error for almost an hour now, after spending the same amount of time trying to fix it. I don't know what I'm missing or what I need. Any help please. I want the user to click on the subscribe button and to have it save and then send them a verification email. This is the error message I keep receiving "SubscribersController#show is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot."

This is the code for my controller-

class SubscribersController < ApplicationController

respond_to? :html, :json

def index
@subscriber = Subscriber.new
end

def show
end

def create
@subscriber = Subscriber.new(subscriber_params)
respond_to do |format|
    if @subscriber.save
      # Tell the UserMailer to send a welcome email after save
      SubscriberMailer.welcome_email(@subscriber).deliver_now

      format.html { redirect_to(@subscriber, notice: 'User was successfully created.') }
      format.json { render json: @subscriber, status: :created, location: @subscriber }
    else
      format.html { render action: 'new' }
      format.json { render json: @subscriber.errors, status: :unprocessable_entity }
    end
  end
end
  • 写回答

0条回答 默认 最新

    报告相同问题?