Model에서 Array로 속성을 설정하는 방법을 가르쳐 주시겠습니까?모델에서 속성을 Array로 설정하는 방법은 무엇입니까?
나는 그것을 시도했지만 내가 push
, each
같은 배열의 방법을 사용할 때, 나는 undefined method `push' for nil:NilClass
내 마이그레이션 모양이 같은 오류가 발생했습니다 :
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :name
t.string :email
t.string :email_confirmation
t.integer :city_ids, array: true
t.text :description
t.timestamps
end
end
end
내가 배열에 속성 city_ids
를 설정하려는 .
당신이 체크 한이 하나 http://reefpoints.dockyard.com/ruby/2012/09/18/rails-4-sneak-peek-postgresql-array- support.html –
감사합니다,하지만 여전히 나에게 도움이되지 않습니다. 배열로 설정된 속성에서 배열 메소드를 사용할 수 없습니다. –