2012-09-23 50 views
0

嵌套形式,我有兩種型號:的Rails 3 DataMapper的

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 

但當我想保存這些值時,我總是得到錯誤: 「屬性'meeting_point'無法訪問簡介」 在控制器 @ profile.update(PARAMS [:資料])

回答

0

我覺得有一個plugin(DM-accepts_nested_attributes),這將解決這個問題 -

類似的問題,更多的細節討論here