Relation#as 将改变 4.0 中的行为。使用 `map_to` 代替
Relation#as will change behavior in 4.0. Use `map_to` instead
在赏花指南中
https://hanamirb.org/guides/1.2/associations/has-many/#usage
当我使用方法时
@book = BookRepository.new.find_with_tickets(params[:id])
我收到一条消息:
[deprecated] Relation#as will change behavior in 4.0. Use `map_to` instead
=> Called at:
/Users/saika/Documents/local/kadai-hanami/ticket_api/lib/ticket_api/repositories/book_repository.rb:7:in `find_with_tickets'
/Users/saika/Documents/local/kadai-hanami/ticket_api/apps/api/controllers/books/show.rb:9:in `call'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/callbacks.rb:195:in `call'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/callable.rb:71:in `block in call'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/throwable.rb:145:in `block in _rescue'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/throwable.rb:143:in `catch'
我不知道应该用什么代替 'map_to'。
您应该将 #as
替换为 #map_to
,它将照常工作。
在赏花指南中 https://hanamirb.org/guides/1.2/associations/has-many/#usage
当我使用方法时
@book = BookRepository.new.find_with_tickets(params[:id])
我收到一条消息:
[deprecated] Relation#as will change behavior in 4.0. Use `map_to` instead
=> Called at:
/Users/saika/Documents/local/kadai-hanami/ticket_api/lib/ticket_api/repositories/book_repository.rb:7:in `find_with_tickets'
/Users/saika/Documents/local/kadai-hanami/ticket_api/apps/api/controllers/books/show.rb:9:in `call'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/callbacks.rb:195:in `call'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/callable.rb:71:in `block in call'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/throwable.rb:145:in `block in _rescue'
/Users/saika/.rvm/gems/ruby-2.4.0/gems/hanami-controller-1.2.0/lib/hanami/action/throwable.rb:143:in `catch'
我不知道应该用什么代替 'map_to'。
您应该将 #as
替换为 #map_to
,它将照常工作。