我想在创建收件人时提醒成功确认但是我收到了错误的模板错误:
ActionView::MissingTemplate - Missing partial recipients/_recipient
with {:locale=>[:fr], :formats=>[:js, :html],
:variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}.
RecipientController.rb
respond_to :html
def index
@recipients = Recipient.all
respond_with(@recipients)
end
def create
@recipient = Recipient.new(recipient_params)
if @recipient.save
#RecipientMailer.confirmer_mon_inscription(@inscription).deliver
#@recipient.destroy
respond_to do |format|
format.html { redirect_to @article,
:notice => 'Thanks for your comment' }
format.js { render 'success_create.js.erb'}
end
else
respond_to do |format|
format.html { redirect_to @article,
:alert => 'Unable to add comment' }
format.js { render 'fail_create.js.erb' }
end
end
end
success_create.js.erb
alert("<%= @recipient.email %>");
fail_create.js.erb
alert("<%= @recipient.errors.full_messages.to_sentence %>");
有一些我不明白的东西,当我已指定要渲染的文件时,为什么我必须为创建操作创建部分_recipient
这是我的表格
<h1>S inscrire à la newsletter</h1>
<div class="newsletter">
<div class="newsletter-contenu">
<%= form_for(@recipient, :remote => true, :html => {:class => "form-group"}) do |f| %>
<div class="field form-group">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="actions form-group">
<%= f.submit "S'inscrire à la newsletter", :class => "btn btn-info" %>
</div>
<% end %>
</div>
</div>