3
나는 다음과 같은 메시지를 받았습니다 :레일스 활성 레코드 ID 대 객체 ID + 활성 :: 관계
경고 : Object # id는 더 이상 사용되지 않습니다. 사용 개체 번호는 내가 읽은
을 것으로, object_id 및 성공하지 Ruby Object#id warnings and Active Record에서 트릭을 시도 :108-125-94-123:toptickets johnnygoodman$ rails c
Loading development environment (Rails 3.0.3)
>> ticket_id = 8899
=> 8899
>> ticket = Ticket.where(:number => ticket_id)
=> [#<Ticket id: 97, name: "Set Up API to Feed Customer Info into Bronto ", number: "8899", category_id: 15, created_at: "2011-01-31 21:24:29", updated_at: "2011-01-31 21:24:29", position: 20>]
>> ticket.id
(irb):3: warning: Object#id will be deprecated; use Object#object_id
=> 2175680980
>> ticket[:id]
TypeError: Symbol as array index
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation.rb:363:in `[]'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation.rb:363:in `send'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation.rb:363:in `method_missing'
from (irb):4
>> ticket.class
=> ActiveRecord::Relation
내가 티켓 조회 할 때이 클래스 액티브 :: 자료 될 것으로 기대. 나는 그 방향을 향하기 위해 무엇을해야할지 잘 모르겠다. 방향을 바꿔야한다.
목표 : 티켓을 쿼리하고 id를 출력한다. 위 예제에서 ID의 값은 97이어야합니다.
감사합니다. 나는 그것의 초심자를 알고있다, 그러나 당신이 모를 때 ... – johnnygoodman