当我使用AJAX和Mailer时出错。如果我删除ReferralMailer行,则错误消失
= render partial: 'referrals/referral', collection: @referrals
= simple_form_for Referral.new, remote: true, validate: true, html: { id: :referral } do |f|
= f.hidden_field :user_id, value: current_user.id
= f.input :email, required: true, label: false do
.input-group
= f.input_field :email, required: true, class: "form-control"
= button_tag(type: 'submit', data: { disable_with: t("helpers.please_wait") }, class: "btn btn-sm btn-success") do
i.fa.fa-pencil
= referral.email
class ReferralsController < ApplicationController
respond_to :html, :js
def index
@referrals = Referral.all
end
def create
@referral = Referral.create(referral_params)
ReferralMailer.new_invite(@referral).deliver_now
end
def new_invite(referral)
@referral = referral
mail to: @referral.email,
subject: "You are Invited"
end
Started POST "/en/referrals" for ::1 at 2018-03-05 15:01:10 +0700
Processing by ReferralsController#create as JS
Parameters: {"utf8"=>"✓", "referral"=>{"user_id"=>"49", "email"=>"[email protected]"}, "button"=>"", "locale"=>"en"} (0.3ms) BEGIN
Referral Exists (0.6ms) SELECT 1 AS one FROM "referrals" WHERE "referrals"."email" = $1 LIMIT $2 [["email", "[email protected]"], ["LIMIT", 1]] SQL (2.8ms) INSERT INTO "referrals" ("email", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["email", "[email protected]"], ["user_id", 49], ["created_at", "2018-03-05 15:01:10.733755"], ["updated_at", "2018-03-05 15:01:10.733755"]](0.7ms) COMMIT
Rendering referral_mailer/new_invite.html.slim
Rendered referral_mailer/new_invite.html.slim (25.5ms)
ReferralMailer#new_invite: processed outbound mail in 66.2ms
Completed 401 Unauthorized in 135ms (ActiveRecord: 4.3ms)
ActionView::Template::Error (Multiple style attributes specified):::1 - - [05/Mar/2018:15:01:10 ICT] "POST /en/referrals HTTP/1.1" 500 2650
http://localhost:3000/referrals -> /en/referrals
任何帮助,将不胜感激
事实证明,new_invite.html.slim中存在拼写错误。
我有不同的文件版本new_invite1.html.slim,new_invite2.html.slim等,并根据推荐活动更改它们。一个人有一个错误导致错误。