Jason Wong
chief executive officer
ionami design, inc
San Francisco, CA
http://www.ionami.com
Personally working on a blog, and experimenting w/CMS''s at the moment.
On Dec 14, 2004, at 5:37 AM,
rails-request-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org wrote:
> Send Rails mailing list submissions to
> rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.rubyonrails.org/mailman/listinfo/rails
> or, via email, send a message with subject or body ''help''
to
> rails-request-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>
> You can reach the person managing the list at
> rails-owner-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Rails digest..."
>
>
> Today''s Topics:
>
> 1. Re: Proposal for Modifications to the ActiveRecord
> Inheritance Model (David Heinemeier Hansson)
> 2. The defaults of single-table inheritance (Part 911)
> (David Heinemeier Hansson)
> 3. Refactoring validations (David Heinemeier Hansson)
> 4. Re: Refactoring validations (Johan S?rensen)
> 5. Re: Refactoring validations (David Heinemeier Hansson)
> 6. Re: Refactoring validations (Demetrius Nunes)
> 7. Best practice for cascading deletes (Demetrius Nunes)
> 8. Re: Refactoring validations (Edgardo Hames)
> 9. Re: Refactoring validations (David Heinemeier Hansson)
> 10. Re: Best practice for cascading deletes (Scott Barron)
> 11. Introduce yourself and your project (David Heinemeier Hansson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 14 Dec 2004 13:27:23 +0100
> From: David Heinemeier Hansson
<david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Subject: Re: [Rails] Proposal for Modifications to the ActiveRecord
> Inheritance Model
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<81B431CA-4DCB-11D9-A57D-000D932CD5BA-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>> The database tables _mammals_ and _birds_ would both be required to
>> implement *at least* the same columns as the table _animals_.
I''ll
>> admit that this makes sense. If you don''t want to have _all_
of the
>> attributes from an _animals_ table here, then it probably makes more
>> sense to use mixins for the specific functionality. My only concern
>> would be the performance impact of enforcing this.
>
> This is exactly what I mean. Lets try to see if a check can be made
> without killing performance. If not, we''ll just recommend it as a
way
> you should design your classes.
>
>> If we put them at the level of siblings, then it would be easy to have
>> both Employee and Account share common information derived form
>> Contact, but there is no explicit relationship between the two. (This
>> would also enable you to create more specializations of Account [say,
>> an AdminAccount] and have an Employee be able to also be one of those
>> instead of just a regular account.
>
> I think this is pretty confusing and overloading and overburdening
> inheritance. I think it would make more sense to use composition
> instead, so you have:
>
> class Account < ActiveRecord::Base
> belongs_to :account
> end
>
> class Contact < ActiveRecord::Base
> has_one :account
> end
>
> class Employee < Contact
> end
>
> I''m not seeing the good of opening up for these kinds of
polymorphism
> circumventions. I think it might clutter the solution space more than
> open it up.
>
>> The problem with this attitude in general (and I''m not
accusing you of
>> doing so intentionally) is that it says "Whoever has been using
this
>> the longest is automatically right---noobs need not complain." And
of
>> course those who have been working with it the longest are, at this
>> point, the least vocal in their "surprise". They''re
used to it; it''s
>> no longer a surprise. ;-)
>
> Newbies do need to complain. And I certainly do need to listen. That
> doesn''t mean I have to agree all the time, though ;)
>
>> BTW, I have a patch ready (against repo version 103, though
I''ll
>> update and integrate to the latest today) that implements the above
>> for STI and CONTI (haven''t tackled CLSTI yet) with unit tests.
Since
>> it could still be considered as a development spike or proof of
>> concept rather than something ready for inclusion in the distribution,
>> is Trac still the best way to get this out there? Or should I send it
>> to you directly, DHH?
>
> Let''s just get it on Trac, then everyone can have a look. And it
sounds
> great! It''ll be very nice to have all of these additional
strategies
> available.
> --
> David Heinemeier Hansson,
> http://www.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://macromates.com/ -- TextMate: Code and markup editor (OS X)
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 14 Dec 2004 13:36:45 +0100
> From: David Heinemeier Hansson
<david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Subject: [Rails] The defaults of single-table inheritance (Part 911)
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<D0B020CD-4DCC-11D9-A57D-000D932CD5BA-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> So I''ve been thinking. How could single-table inheritance remain
the
> default mode of operations while still appeasing the desire to work
> with inheritance in a way that didn''t relate to mapping.
>
> I think I just might have the first swing at such an approach. If the
> inheritance_column isn''t available in the table, then single-table
> inheritance doesn''t kick in. If it is present, everything works as
it
> does now. The implementation is terribly simple:
>
> def descends_from_active_record?
> superclass == Base ||
> !columns_hash.has_key?(inheritance_column)
> end
>
> In fact, it''s so simple that I''m suspecting more might
need to be done.
> But let''s hear from the expert in inheritance-without-mapping,
Curt
> Sampson, on that.
>
> I also improved the error message you get if you by accident attempt to
> use a column called "type" for something else than storing the
> inheritance class data. Example:
>
> ActiveRecord::SubclassNotFound:
> The single-table inheritance mechanism failed
> to locate the subclass: ''bad_class!''. This error
> is raised because the column ''type'' is reserved
> for storing the class in case of inheritance.
>
> Please rename this column if you didn''t intend it
> to be used for storing the inheritance class or
> overwrite Company.inheritance_column to use another
> column for that information.
>
> Could it be? Happiness and bliss all around in inheritance land :)? I
> think it just might!
> --
> David Heinemeier Hansson,
> http://www.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://macromates.com/ -- TextMate: Code and markup editor (OS X)
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 14 Dec 2004 13:54:21 +0100
> From: David Heinemeier Hansson
<david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Subject: [Rails] Refactoring validations
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<466461BE-4DCF-11D9-A57D-000D932CD5BA-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> On IRC, JS just posted an example of how a Person class with regular
> validations might look:
>
> http://rafb.net/paste/results/UnD6ZG15.html
>
> Here''s how the Rails 0.9 refactored version looks:
>
> http://rafb.net/paste/results/gHymzM53.html
>
> Pretty neat ;)
> --
> David Heinemeier Hansson,
> http://www.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://macromates.com/ -- TextMate: Code and markup editor (OS X)
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 14 Dec 2004 14:01:55 +0100
> From: Johan S?rensen <johans-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Subject: Re: [Rails] Refactoring validations
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<6890597404121405017424c297-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Actually, _all_ the stuff in 0.9 looks sweet. Can''t wait to play
> around with it! (I''ve been putting off updating to the beta/edge
> stuff).
>
> While I''m sure a lot of "purists" has some issues with
these kind of
> things, but for me, it''s stuff like this that makes Rails
interesting;
> that I don''t have to do work that the framework could/should be
doing.
>
> "sustainable productivity" ;)
>
> -- johan
>
>
> On Tue, 14 Dec 2004 13:54:21 +0100, David Heinemeier Hansson
> <david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org> wrote:
>> On IRC, JS just posted an example of how a Person class with regular
>> validations might look:
>>
>> http://rafb.net/paste/results/UnD6ZG15.html
>>
>> Here''s how the Rails 0.9 refactored version looks:
>>
>> http://rafb.net/paste/results/gHymzM53.html
>>
>> Pretty neat ;)
>> --
>> David Heinemeier Hansson,
>> http://www.basecamphq.com/ -- Web-based Project Management
>> http://www.rubyonrails.org/ -- Web-application framework for Ruby
>> http://macromates.com/ -- TextMate: Code and markup editor (OS
>> X)
>> http://www.loudthinking.com/ -- Broadcasting Brain
>>
>> _______________________________________________
>> Rails mailing list
>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
>
> --
> Johan Sørensen
> Professional Futurist
> www.johansorensen.com
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 14 Dec 2004 14:06:29 +0100
> From: David Heinemeier Hansson
<david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Subject: Re: [Rails] Refactoring validations
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org, Johan S?rensen
<johans-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Message-ID:
<F8352AF1-4DD0-11D9-A57D-000D932CD5BA-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>> While I''m sure a lot of "purists" has some issues
with these kind of
>> things, but for me, it''s stuff like this that makes Rails
interesting;
>> that I don''t have to do work that the framework could/should
be doing.
>
> Yeah, I had a few puristic gripes with it at first. But when I saw how
> well it was working, those quickly went away. I''ll chose practical
> application over purity any time of the week. Luckily, what is _really_
> pure is often also very practical :)
> --
> David Heinemeier Hansson,
> http://www.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://macromates.com/ -- TextMate: Code and markup editor (OS X)
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>
> ------------------------------
>
> Message: 6
> Date: Tue, 14 Dec 2004 11:15:14 -0300
> From: Demetrius Nunes
<demetrius-fDpYTK8McCzCdMRJFJuMdgh0onu2mTI+@public.gmane.org>
> Subject: Re: [Rails] Refactoring validations
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<41BEF572.6050109-fDpYTK8McCzCdMRJFJuMdgh0onu2mTI+@public.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> David, what is the intended release date for 0.9?
>
> I am developing my masters degree using Rails 0.8.5 and I am heavily
> dependant on its productivity gains to pull this one out.
>
> Thanks a lot
> Demetrius
>
> David Heinemeier Hansson wrote:
>
>>> While I''m sure a lot of "purists" has some
issues with these kind of
>>> things, but for me, it''s stuff like this that makes Rails
>>> interesting;
>>> that I don''t have to do work that the framework
could/should be
>>> doing.
>>
>>
>> Yeah, I had a few puristic gripes with it at first. But when I saw how
>> well it was working, those quickly went away. I''ll chose
practical
>> application over purity any time of the week. Luckily, what is
>> _really_ pure is often also very practical :)
>> --
>> David Heinemeier Hansson,
>> http://www.basecamphq.com/ -- Web-based Project Management
>> http://www.rubyonrails.org/ -- Web-application framework for Ruby
>> http://macromates.com/ -- TextMate: Code and markup editor (OS
>> X)
>> http://www.loudthinking.com/ -- Broadcasting Brain
>>
>> _______________________________________________
>> Rails mailing list
>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>>
>
>
>
> ------------------------------
>
> Message: 7
> Date: Tue, 14 Dec 2004 11:26:36 -0300
> From: Demetrius Nunes
<demetrius-fDpYTK8McCzCdMRJFJuMdgh0onu2mTI+@public.gmane.org>
> Subject: [Rails] Best practice for cascading deletes
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<41BEF81C.8080103-fDpYTK8McCzCdMRJFJuMdgh0onu2mTI+@public.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I am using a MySql backend to support a model that has several has_many
> relationships.
>
> Yesterday I noticed that Rails is not cascading a delete on a parent
> object to its children as I thought it would do automatically. (I am
> not
> using foreign key constraints, at least for now).
>
> So, should I implement this cascading using rails/ruby code or is it
> better to implement this using the database and foreign key
> constraints?
>
> By the way, I''ve been working with "robust"
technologies, like Java and
> .NET for at least 8 years, and I am often amazed with how much I can
> get
> from so few lines of code using Ruby on Rails. This is by far the most
> enjoyable web framework/language combination I''ve ever used.
>
> Thanks a lot,
> Demetrius
>
>
>
> ------------------------------
>
> Message: 8
> Date: Tue, 14 Dec 2004 10:33:20 -0300
> From: Edgardo Hames <ehames-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Subject: Re: [Rails] Refactoring validations
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<478c16ae041214053310a64794-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII
>
> On Tue, 14 Dec 2004 13:54:21 +0100, David Heinemeier Hansson
> <david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org> wrote:
>>
>> Here''s how the Rails 0.9 refactored version looks:
>>
>> http://rafb.net/paste/results/gHymzM53.html
>>
>
> In line no. 7, the "unless" keyword is repeated. Is that right?
>
> Kind Regards,
> Ed
> --
> Pretty women make us buy beer, ugly women make us drink beer
>
>
> ------------------------------
>
> Message: 9
> Date: Tue, 14 Dec 2004 14:35:21 +0100
> From: David Heinemeier Hansson
<david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Subject: Re: [Rails] Refactoring validations
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<0060BCC4-4DD5-11D9-A57D-000D932CD5BA-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>> David, what is the intended release date for 0.9?
>
> It''s been said so much, but "This Week" (tm) :). No
really. The new
> dispatcher stuff won''t make it in, I just decided. Rails 0.9
already
> contains so much stuff that''ll it be huge upgrade for most people.
> Let''s get it out.
>
> So over the next couple of days is the plan.
>
>> I am developing my masters degree using Rails 0.8.5 and I am heavily
>> dependant on its productivity gains to pull this one out.
>
> Excellent. What project are you working on?
> --
> David Heinemeier Hansson,
> http://www.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://macromates.com/ -- TextMate: Code and markup editor (OS X)
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>
> ------------------------------
>
> Message: 10
> Date: Tue, 14 Dec 2004 08:37:14 -0500
> From: Scott Barron <scott-HDQKq3lYuGDk1uMJSBkQmQ@public.gmane.org>
> Subject: Re: [Rails] Best practice for cascading deletes
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<20041214133714.GA1427-HDQKq3lYuGDk1uMJSBkQmQ@public.gmane.org>
> Content-Type: text/plain; charset=us-ascii
>
> On Tue, Dec 14, 2004 at 11:26:36AM -0300, Demetrius Nunes wrote:
>> I am using a MySql backend to support a model that has several
>> has_many
>> relationships.
>>
>> Yesterday I noticed that Rails is not cascading a delete on a parent
>> object to its children as I thought it would do automatically. (I am
>> not
>> using foreign key constraints, at least for now).
>>
>> So, should I implement this cascading using rails/ruby code or is it
>> better to implement this using the database and foreign key
>> constraints?
>>
>> By the way, I''ve been working with "robust"
technologies, like Java
>> and
>> .NET for at least 8 years, and I am often amazed with how much I can
>> get
>> from so few lines of code using Ruby on Rails. This is by far the most
>> enjoyable web framework/language combination I''ve ever used.
>>
>> Thanks a lot,
>> Demetrius
>
> The has_one and has_many relationships both have a dependent option
> that
> will kill off the object they''re linked to. I believe the habtm
> relationship will remove its entries from the join table when it is
> destroyed but I don''t think there is any implicit destruction of
the
> objects it is linked to (since they can be linked to other objects in
> the table you''re destroying an object from).
>
> I don''t remember if these are in 0.8.5 or not, I''ve been
using rails
> from svn for a while now and some features have blurred versions for me
> ;)
>
> -Scott
>
>
> ------------------------------
>
> Message: 11
> Date: Tue, 14 Dec 2004 14:37:19 +0100
> From: David Heinemeier Hansson
<david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Subject: [Rails] Introduce yourself and your project
> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<46D88B46-4DD5-11D9-A57D-000D932CD5BA-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> I''m seeing a lot of new names on the list. Could we perhaps do a
round
> of introductions? That would also be a great first post, if you
haven''t
> had a chance to contribute yet. The basics should include your name,
> your organization, your country and city, and the project you''re
> currently working on.
>
> I''ll start:
>
> David Heinemeier Hansson,
> Working with 37signals
> Live in Copenhagen, Denmark, but are working with people in Chicago, US
> Basecamp and the forthcoming Writeboard
>
> Who''s next?
> --
> David Heinemeier Hansson,
> http://www.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://macromates.com/ -- TextMate: Code and markup editor (OS X)
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>
> ------------------------------
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
> End of Rails Digest, Vol 3, Issue 37
> ************************************
>