Devise中的NoMethodError :: Registrations #create

时间:2014-06-30 06:40:28

标签: ruby-on-rails ruby twitter-bootstrap devise

我正在尝试使用bootstrap设置ruby中的默认警报消息,我遇到了需要自定义代码的捏,但我得到的只是这个

我无法在此处找到服务器返回的问题


Showing c:/users/aaron/jobonaut/app/views/devise/registrations/new.html.erb where line #4 raised:

undefined method `full' for #<ActiveModel::Errors:0x3844458>
Extracted source (around line #4):
1
2
3
4
5
6
7

  <h2>Sign up</h2>

  <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
    <!--<%= devise_error_messages! %> -->

    <div class="form-group">
    <%= f.label :email %>

这是我到目前为止编写的代码

module DeviseHelper
        def devise_error_messages!
        return '' if resource.errors.empty?

        messages = resource.errors.full.messages.map {|msg| content_tag(:li, msg) }.join
        sentence = I18n.t('errors.messages.not_saved', count: resource.errors.count, resource: resource.class.model.name.human.downo)

        html = <<-HTML
        <div class="alert alert-danger alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <h4>#{sentence}</h4>
            #{messages}
        </div>
    HTML

    html.html_safe
    end
end

1 个答案:

答案 0 :(得分:1)

应该只是resource.errors.full_messages