On Mon, Dec 21, 2009 at 10:40 AM, Jeremy Evans <[email protected]>wrote:

> On Dec 20, 6:14 pm, hendra kusuma <[email protected]> wrote:
> > a = Model[record_id].? do |rec|
> > or
> > a = Model.filter(:id=>record_id).? do |rec|
> >
> > Sorry if the question is so dumb
>
> If you are asking for a method that lets you lookup a model by id,
> yield it to the block, and save it, I don't believe there is one (if
> you want something else, please be more specific).  I recommend the
> following instead:
>
>  rec = Model[record_id]
>  # modify rec as appropriate
>  rec.save
>
> If you really want to use a block form:
>
>  class Sequel::Model
>    def self.update_block(id)
>      s = self[id]
>      yield s
>      s.save
>    end
>  end
>
> Then you could do:
>
>  a = Model.update_block(record_id) do |rec|
>   ...
>  end
>
> I still don't see any advantages to that approach, though.
>
> Jeremy
>
>
Sorry,
I never expect those date in string problem does not exist in Model[id]
only in Model.new, and you have give me a way with Model.create block form
and yes, you are right
there's no point in having that approach

Thank you
Regards
Hendra

-- 
Suka linux?
Kunjungi blog saya http://penguinroad.blogspot.com

--

You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.


Reply via email to