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