Undefined method 'on' for ActionModel

前端 未结 2 1480
攒了一身酷
攒了一身酷 2021-01-04 20:27

I\'m getting the following error:

NoMethodError in Users#new

Showing .../app/views/users/form/_new.haml where line #7 raised:

undefined method `on\' for #&         


        
相关标签:
2条回答
  • 2021-01-04 20:41

    If you're using Rails 3, then the problem is that there's no "on" method for the Errors class anymore. I think you're supposed to use "get" now. So:

    error = case errors = model.errors.get(field)
    

    Or...

    error = case errors = model.errors[field]
    
    0 讨论(0)
  • 2021-01-04 20:53

    I checked my user and u.errors is an ActiveRecord::Errors, while I see you have an ActiveModel::Error, I would work on that.

    Then I don't understand case errors = statement in your helper, I'm curious to know how you implemented that part...

    0 讨论(0)
提交回复
热议问题