Forum: Ruby on Rails How to use Route class in migrations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C25909d53e693206a9ec8cbf0631092e?d=identicon&s=25 Witold Rugowski (viciu)
on 2007-05-21 11:40
Hi!
In my application I have Route model. In migration I have to make some
operations on all routes, however simple Route.find(:all).each does not
work:

rake aborted!
undefined method `find' for
#<ActiveRecord::ConnectionAdapters::MysqlAdapter:0x8d9c2c4>

Well I ran on this issue back in January and found that there is some
name conflict since when I run this code in migration:

puts ActiveRecord::Base::Route.superclass
puts ActiveRecord::Base::Owner.superclass

Result is:
ActiveRecord::Migration
ActiveRecord::Base

In January I have used dirty hack, stopping migration and running
external script. But I have to make some changes again, which require me
to update all routes. Is there some proper way to call Route.find(:all)?

Maybe I have to get used to external script or rename model from Route
to something other?


In case someone interested in details here are they:

<http://nhw.pl/wp/2007/01/03/migrations-headache/>


--
Witold Rugowski
http://nhw.pl/wp/ (EN blog)
http://nhw.pl/pl/ (PL blog)
This topic is locked and can not be replied to.