This plugin I made allows you to set AR model attributes to "db
functions"
http://www.agilewebdevelopment.com/plugins/activerecord_database_functions
>> User.new
>> user.password = ActiveRecord::Base::DBFunction.new( :password,
''secret'' )
>> user.save
>> user.password
=> "428567f408994404"
>> class User < ActiveRecord::Base
>> def password=( pass )
>> write_attribute :password, DBFunction( :password, pass )
>> end
>> end
>> user = User.new
>> user.password = ''secret''
>> user.save
>> user.password
=> "428567f408994404"
or for you...>> locations.point = ActiveRecord::Base::DBFunction.new( :GeomFromText,
>> ActiveRecord::Base::DBFunction( :POINT, lat, lng ) )
Let me know if that helps!
mark
On 8/18/06, Noah Davis <noah.box@gmail.com> wrote:>
> I''m trying to determine how/if I can use MySql''s spatial
extensions
> with ActiveRecord. The spatial extensions usually require inserts in
> the following format:
>
> INSERT INTO `locations` (name, point) VALUES ("location
> name",GeomFromText(''POINT(<lng>
<lat>''));
>
> And reads as
>
> SELECT name, AsText(point) AS point FROM locations;
>
> While I understand there''s methods to issue custom finder
commands, I
> don''t recall seeing anything about custom inserts/updates.
>
> Does anyone have any recommendations on how I might handle a situation
> like this?
>
> Thanks in advance.
>
> Noah
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Mark Van Holstyn
mvette13@gmail.com
http://lotswholetime.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060818/25940805/attachment.html