0

私は2つのモデルを持っています:

class MeetingPoint

    include DataMapper::Resource

    belongs_to :profile

    property :id, Serial
    property :lat, String

end

class Profile

    include DataMapper::Resource
    has n, :meeting_points

    property :id, Serial

    property :distance, Text
    property :created_at, DateTime
    property :updated_at, DateTime

end

ここで、プロファイルと meeting_poing を編集するフォームを作成します。

= form_for @profile do |f| 

    = f.text_field :distance
    = f.fields_for  @profile.meeting_points do |ff|
        = ff.text_field :lat
    = f.submit

しかし、値を保存したいときは常にエラーが発生します: "The attribute 'meeting_point' is notaccessible in Profile" in controller @profile.update(params[:profile])

4

1 に答える 1

0

この問題を修正するプラグイン(dm-accepts_nested_attributes) があると思います-

同様の問題と詳細については、こちらで説明しています

于 2013-05-26T11:04:42.970 に答える