SunQuest
           Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 11th, 2008, 07:07 PM
paulkoan's Avatar
paulkoan paulkoan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 137 paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 21 h 9 m 54 sec
Reputation Power: 31
Rails ActiveRecord and CakePHP interoperation

In the interests of "using the right tool for the right job", I am using the Rails activerecord library and CakePHP to interact with the same database tables.

In the main, these two are largely interoperable - they use the same conventions for relationships between tables, otherwise it would be a no-go.

Where it falls down is the Rails use of "created_at" and "updated_at" while CakePHP uses "created" and "updated" or "modified".

Is it possible with rails or with cake to change the names of the automagic model fields without resorting to hacking the core code?

If mysql supported aliases for fields within the table structure also, that would be excellent!

Cheers,

Paul

Reply With Quote
  #2  
Old March 12th, 2008, 06:15 AM
L7Sqr L7Sqr is online now
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Constant Limbo
Posts: 590 L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 13 h 35 m 41 sec
Reputation Power: 100
Send a message via AIM to L7Sqr
If you are just looking to rename/alias a method, ruby supports this.
Code:
irb(main):001:0> class Array
irb(main):002:1> alias_method :my_each, :each
irb(main):003:1> end
=> Array
irb(main):004:0> a = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
irb(main):005:0> a.my_each { |x| puts x }
1
2
3
4
5
=> [1, 2, 3, 4, 5]
irb(main):006:0>

Realize that I know nothing of Rails or Cake, but it sounds like this is what you were looking for. Feel free to ignore if I completely missed the mark
__________________
-- I'll provide you with reference points; if they dont work, refer to something else.

If you process text, this might make your life a little easier.

Reply With Quote
  #3  
Old March 12th, 2008, 04:41 PM
paulkoan's Avatar
paulkoan paulkoan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 137 paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level)paulkoan User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 21 h 9 m 54 sec
Reputation Power: 31
Yeah, that is handy, but I am not sure that I can use it in this case.

I would imagine the ORM would make the class names and table column names the same, I don't think aliasing one would make it choose a different column name down in the depths of the class heirachy...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Rails ActiveRecord and CakePHP interoperation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway