Thanks for all the help on this issue - I learned a lot more than I
expected from the discussion.

Looks like the save! method would be the way forward.

After all this though, I actually went back and implemented it in a
different way so the url didn't need to be saved in the database after
all and could be reconstructed from the id value. This meant I could
just use a method like Kristian suggested:

  def url
    "/mysite/#{self.id}"
  end

Thanks again for the ideas and advice everyone,

DAZ

On Apr 7, 11:38 am, Piotr Solnica <[email protected]> wrote:
> On Apr 7, 11:45 am, DAZ <[email protected]> wrote:
>
> > I still don't see why the code with self.save! works, but self.save
> > doesn't - there aren't any validations or callbacks from what you've
> > both said, both of these methods should work, but self.save just fails
> > silently (the new url field is not saved, but everything else is).
>
> It's because #create calls #save under the hood and the entire
> procedure is called within a block that prevents #save from being
> called more than once to avoid infinite loops. That's why when you
> call #save! it works. I think this is something we really need to
> improve. I know that Dan wants to re-work the Hooks in general, we've
> already added that to 1.2 roadmap...
>
> Cheers
>
> # solnic

-- 
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