Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 验证表单时不显示错误消息_Ruby On Rails - Fatal编程技术网

Ruby on rails 验证表单时不显示错误消息

Ruby on rails 验证表单时不显示错误消息,ruby-on-rails,Ruby On Rails,验证表单时,必须显示错误消息。但是它没有显示出来 我的观点是这样的: <% form_for :invite, :url => profile_invites_path do |f| -%> <%= f.error_messages %> <p><label for="email_to"><%= t 'invites.new.labels.mail'%></label><br/> <%= f.text

验证表单时,必须显示错误消息。但是它没有显示出来

我的观点是这样的:

<% form_for :invite, :url => profile_invites_path do |f| -%>
<%= f.error_messages %>
<p><label for="email_to"><%= t 'invites.new.labels.mail'%></label><br/>
<%= f.text_field :email_to %></p>

<p><label for="role_id"><%= t 'invites.new.labels.role'%></label><br/>
<%= collection_select(:invite, :type, Role.players , :name, :printable_name) %></p>

<p><label for="message"><%= t 'invites.new.labels.message'%></label><br/>
<%= f.text_area :message %></p>

<p><%= submit_tag "#{ t 'application.send'}" %></p>
<% end -%>
我们应该这样做:

<% form_for @invite, :url => profile_invites_path do |f| -%>
profile_邀请_路径do|f|-%

不,我有其他带符号的表单,这些表单都有错误。对不起,其他的注释不好。这个错误是我的。你的解决方案是正确的对不起。现在我有另一个问题。验证显示,但当我再次尝试提交表单时,会出现下一个错误:未知操作无操作响应2。操作:拒绝访问、回复消息、检查角色、连接、销毁图片、断开连接、编辑、联网、新建、接收消息、角色要求、角色要求=、s、保存图片、发送消息、显示、提交待决请求、切换网络视图、更新、消极投票和积极投票声音,如表单路由不正确。我怀疑您不再提供指向路径的url,而helper的表单_正在尝试猜测它。你能在你的问题中发布你当前的代码表吗。另外,从控制台运行rake路由将显示您定义的所有路由。
<% content_for :header do -%>
<% t 'invites.new.title'%> <%= configatron.site_name %>
<% end -%>

<% content_for :sidebar do -%>

<p>
    <% t 'invites.new.indication'%>
</p>
<% end -%>



<% form_for @invite, :url => profile_invites_path do |f| -%>
<%= f.error_messages %>
<p><label for="email_to"><%= t 'invites.new.labels.mail'%></label><br/>
<%= f.text_field :email_to %></p>

<p><label for="role_id"><%= t 'invites.new.labels.role'%></label><br/>
<%= collection_select(:invite, :type, Role.players , :name, :printable_name) %></p>

<p><label for="message"><%= t 'invites.new.labels.message'%></label><br/>
<%= f.text_area :message %></p>

<p><%= submit_tag "#{ t 'application.send'}" %></p>
<% end -%>

<%= link_to "#{ t 'application.back'}", profile_invites_path %>
def new
    @invite = Invite.new
  end

  def index
    @profile = current_user.profile
    @ps_invites = Invite.of_profile(@profile.id).for_powerful_supplier.available.count
    @ubc_invites = Invite.of_profile(@profile.id).for_business_contact.available.count

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @invites }
    end
  end

  def create
    @invite = Invite.of_type(params[:invite][:type]).of_profile(current_user.profile.id).available.first

    unless @invite.nil?
      @invite.status = 'pending'
      @invite.message = params[:invite][:message]
      @invite.email_to = params[:invite][:email_to]
      if @invite.save
        InviteMailer.deliver_send_invite(@invite)
        flash.now[:notice] = t 'invites.messages.sent'
        redirect_to(profile_invites_url)
      else
        flash.now[:error] =  t "invites.messages.not_sent"
        render :controller => 'invites' ,:action => "new"
      end
    else
      flash.now[:error] = t("invites.messages.without_invite", :profile_type => params[:invite][:type])
      render :controller => 'invites' ,:action => "new"
    end
  end
end
<% form_for @invite, :url => profile_invites_path do |f| -%>