errors.full_messages | wrong number of arguments (given 2, expected 0..1)

341 Views Asked by At

It works out and shows where the error is

- if @star.errors.any?
     div class="alert alert-danger"
        ul class="mb-0"
          - @star.errors.each do |message|
            li
              = message

but I want to see a complete error...

- if @star.errors.full_messages.any?
      div class="alert alert-danger"
        ul class="mb-0"
          - @star.errors.full_messages.each do |message|
            li
              = message

then I get an error

wrong number of arguments (given 2, expected 0..1)enter image description here

1

There are 1 best solutions below

0
LihnNguyen On

I think that this error is here.

@star.errors: #ActiveModel:Errors = [#ActiveModel::Error attribute=user, type=blank, options={:message=>:required}, #ActiveModel::Error attribute=user_id, type=blank, options={}, ...]

- if @star.errors.any?
      div class="alert alert-danger"
        ul class="mb-0"
          - @star.errors.each do |message|
            li
              = message.full_messeage 
           // Result: - User must exist
                      - User can't be blank