I knew I shouldn't use dummy code. In reality it's because I've got
some rather complex logic, actually requiring
parent-children-grandparent in the same interface or it would be a
very flawed user experience.

2008/8/26 John W Higgins <[EMAIL PROTECTED]>:
> Your logic seems rather flawed in this one. A "user" form shouldn't be
> modifying book titles. It would seem rather difficult to setup as well. It
> would be difficult to distinguish between the scenario where the user is
> checking out another book and when you would be magically changing the title
> of a book from within the user screen. I don't think this is a data mapper
> issue - you should really re-examine your data flow on this one.
>
> John
>
> On Tue, Aug 26, 2008 at 1:59 AM, harry <[EMAIL PROTECTED]> wrote:
>>
>> Then I could avoid creating a custom update-function, for complex forms.
>>
>> 2008/8/26 Abdul-Rahman Advany <[EMAIL PROTECTED]>:
>> >
>> > Why not u.library.update_attributes?
>> >
>> > On 26 aug, 02:41, "harry jr." <[EMAIL PROTECTED]> wrote:
>> >> Hello. Suppose I have this model:
>> >>
>> >> class User
>> >>   include DataMapper::Resource
>> >>   property :id, Integer, :serial => true
>> >>   property :name, String
>> >>
>> >>   has 1, :library
>> >>   has n, :books
>> >> end
>> >>
>> >> class Library
>> >>   include DataMapper::Resource
>> >>   property :id, Integer, :serial => true
>> >>   property :name, String
>> >>
>> >>   belongs_to :user
>> >> end
>> >>
>> >> class Book
>> >>   include DataMapper::Resource
>> >>   property :id, Integer, :serial => true
>> >>   property :title, String
>> >>
>> >>   belongs_to :user
>> >> end
>> >>
>> >> Then I can do this in IRB:
>> >>
>> >> > u = User.create(:name => "harry", :library => {:name => 'West Side'},
>> >> > :books => [{:title => "How to Win"}, {:title => "How Not to Lose"}])
>> >>
>> >> => #<User id=4 name="harry" password=nil>>> u.library
>> >>
>> >> => #<Library id=4 name="West Side" user_id=4>>> u.books
>> >>
>> >> => [#<Book id=4 title="How to Win" user_id=4>, #<Book id=5 title="How
>> >> Not to Lose" user_id=4>]>> u.update_attributes(:library => {:name =>
>> >> 'East Side'})
>> >> => true
>> >> >> u.library
>> >>
>> >> => #<Library id=5 name="East Side" user_id=4>
>> >>
>> >> But how would i do a u.update_attribtues to change the title of book
>> >> with id 5 to 'My Story' ?
>> > >
>> >
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to