|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
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... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Ruby Programming > Rails ActiveRecord and CakePHP interoperation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|