# How to use Route class in migrations

**URL:** <https://www.ruby-forum.com/t/how-to-use-route-class-in-migrations/104661>\
**Category:** Rails\
**Created:** [May 21, 2007, 11:40am UTC](https://www.ruby-forum.com/t/how-to-use-route-class-in-migrations/104661 "2007-05-21T11:40:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![viciu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@viciu](https://www.ruby-forum.com/u/viciu)\
**Post date:** [May 21, 2007, 11:40am UTC](https://www.ruby-forum.com/t/how-to-use-route-class-in-migrations/104661/1 "2007-05-21T11:40:05Z")

</div>

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/](http://nhw.pl/wp/2007/01/03/migrations-headache/)

–  
Witold R.  
[nhw.pl](http://nhw.pl/wp/) (EN blog)  
[NetManiac](http://nhw.pl/pl/) (PL blog)
