Article View: pl.comp.lang.ruby
Article #828Re: RoR vs PHP
From: Maciej Piechotka
Date: Wed, 02 Jan 2008 08:33
Date: Wed, 02 Jan 2008 08:33
45 lines
2784 bytes
2784 bytes
On Wed, 02 Jan 2008 03:53:39 +0000, Jaroslaw Zabiello wrote: > On Tue, 01 Jan 2008 23:14:53 -0000, Jaroslaw Zabiello <abuse@tpnet.pl> > wrote: > >> class Child1 < Sequel::Model(:childs1) >> set_schema do >> primary_key :parent_id >> varchar :pole1 >> end >> class << self >> def next_id >> self.select(:max[:parent_id].as(:last_id)).first.last_id.to_i + >> 1 >> end >> end >> before_save do >> unless Parent.filter(:id => Child1.next_id).first >> raise 'Parent cannot assign more childs1 objects' >> end >> end >> end > > To samo, ale krócej: > > class Child1 < Sequel::Model(:childs1) > set_schema do > primary_key :parent_id > varchar :pole1 > end > before_save do > unless Parent[Child1.max(:parent_id).to_i + 1] > raise 'Parent cannot assign more childs1 objects' > end > end > end Ale Child1 nie jest pochodną klasy Parent. W ruby oczywiście nie stanowi to dużego problemu, ale w pewnych przypadkach może. Pozdrawiam -- I've probably left my head... somewhere. Please wait untill I find it. Homepage (pl_PL): http://uzytkownik.jogger.pl/ (GNU/)Linux User: #425935 (see http://counter.li.org/)
Technical Details
Message-ID:
<rrur45-29m.ln1@router.piechotka.com.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.internetia.pl!nnrpd.internetia.plReferences:
<fl6ahk$m1q$1@inews.gazeta.pl> <op.t351icnsr2rg33@jzmbp.local> <fl93bh$d8p$1@inews.gazeta.pl> <r4il45-1ar.ln1@router.piechotka.com.pl> <op.t358bkfwr2rg33@jzmbp.local> <fl9aau$9b9$5@inews.gazeta.pl> <20071231084648.6d47feda.gryf_esm-no@spam-o2.pl> <op.t37dq3ydr2rg33@jzmbp.local> <0enn45-u25.ln1@router.piechotka.com.pl> <op.t37qnpdrr2rg33@jzmbp.local> <3pbo45-ha7.ln1@router.piechotka.com.pl> <op.t3777x1jr2rg33@jzmbp.local> <jtip45-n8c.ln1@router.piechotka.com.pl> <op.t388lvhur2rg33@jzmbp.local> <h96q45-37f.ln1@router.piechotka.com.pl> <op.t39jhmarr2rg33@jzmbp.local> <grhq45-5dg.ln1@router.piechotka.com.pl> <op.t39xi4kdr2rg33@jzmbp.local> <op.t4aafpggr2rg33@jzmbp.local>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.internetia.pl!nnrpd.internetia.pl From: Maciej Piechotka <uzytkownik2@gmail.com> Newsgroups: pl.comp.lang.ruby Subject: Re: RoR vs PHP Date: Wed, 2 Jan 2008 09:33:31 +0100 Organization: Netia S.A. Lines: 46 Message-ID: <rrur45-29m.ln1@router.piechotka.com.pl> References: <fl6ahk$m1q$1@inews.gazeta.pl> <op.t351icnsr2rg33@jzmbp.local> <fl93bh$d8p$1@inews.gazeta.pl> <r4il45-1ar.ln1@router.piechotka.com.pl> <op.t358bkfwr2rg33@jzmbp.local> <fl9aau$9b9$5@inews.gazeta.pl> <20071231084648.6d47feda.gryf_esm-no@spam-o2.pl> <op.t37dq3ydr2rg33@jzmbp.local> <0enn45-u25.ln1@router.piechotka.com.pl> <op.t37qnpdrr2rg33@jzmbp.local> <3pbo45-ha7.ln1@router.piechotka.com.pl> <op.t3777x1jr2rg33@jzmbp.local> <jtip45-n8c.ln1@router.piechotka.com.pl> <op.t388lvhur2rg33@jzmbp.local> <h96q45-37f.ln1@router.piechotka.com.pl> <op.t39jhmarr2rg33@jzmbp.local> <grhq45-5dg.ln1@router.piechotka.com.pl> <op.t39xi4kdr2rg33@jzmbp.local> <op.t4aafpggr2rg33@jzmbp.local> NNTP-Posting-Host: 77-253-113-55.adsl.inetia.pl Mime-Version: 1.0 X-Trace: mx1.internetia.pl 1199265027 16939 77.253.113.55 (2 Jan 2008 09:10:27 GMT) X-Complaints-To: abuse@inetia.pl NNTP-Posting-Date: Wed, 2 Jan 2008 09:10:27 +0000 (UTC) X-Tech-Contact: usenet@internetia.pl X-Orig-Path: router.piechotka.com.pl!news User-Agent: Pan/0.132 (Waxed in Black) X-Server-Info: http://www.internetia.pl/news/ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit