On 4/20/06, Bryan Stevenson <[EMAIL PROTECTED]> wrote:
> > Remember our class that provides this looks like this
> >
> > class Order < ActiveRecord::Base
> > end
> >
> > I could also do this
> >
> > Order.find_by_state("Virginia")
> >
> > Note that I'm not adding that method to the code. It just gets figured
> > out. I can do this too
> >
> > Order.find_by_state_and_firstname("Virginia","Bob")
>
> Well John I'll have to investigate further.  If you are saying that Ruby has
> built in methods in a buiult-in class called order, then that is pretty
> interesting.  I may also have completely missed what you were saying ;-)

No, I'm saying Order extends ActiveRecord::Base. ActiveRecord:Base is
the class that provides the active record functionality. When you
build a Rails app with the generator, every model object automatically
looks like this

class theObjectYouWantInTheModel < ActiveRecord::Base
end


> I must say this line scares me:
>
> > Note that I'm not adding that method to the code. It just gets figured
> > out. I can do this too
>
> How the hell does it "just know what to do with it" if the method isn't even
> defined???

Reflection. And lots of Ruby-specific magic. Reflection is how
Hibernate (Java) can just figure out data types, etc to build your
objects on the fly. And just like Arf! and Reactor in CF know how to
model database objects. It's pretty common in metaprogramming.

Now the specifics of how ruby (not rails, ruby) can add methods on the
fly is a Ruby-specfic feature that's *really* cool. But CF can add
methods on the fly as well (see all the recent discussion of Mixins on
the list for example.

The real value of Rails is that it's an integrated package of really
well-thought-out base components that work together really well for
building web applications. But if I have to pick one part that knocks
it out of the park, it's ActiveRecord -- I want just that for CF (Arf
is a good start) which can then be plugged into any VC controller you
want (MG, MachII, FB to name a few).

> Cheers
>
> Bryan Stevenson B.Comm.
> VP & Director of E-Commerce Development
> Electric Edge Systems Group Inc.
> phone: 250.480.0642
> fax: 250.480.1264
> cell: 250.920.8830
> e-mail: [EMAIL PROTECTED]
> web: www.electricedgesystems.com
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:238401
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to