Topic: Probing Rails Internal as part of migrating a heavily customized App


I am migrating a highly customized Rails 2 app to Rails 3, and am forced to look into the deep down
architecture/flow of Rails 3 from the ground up, literally from scratch to get the full picture,
so that the migration process can be handled better.

I don't want to use any generate mecahnisms, including the well-known and
documented "rails new ...", as I wan't to start from scratch to be able to fit in the customized app.

Here's what I did - just created the very minimalistic structure to be able to start the rails console ...

$ find . -type f

I could start the rails console ...

Loading development environment (Rails 3.2.2)

But, the Rails Console does not recognize the only model that I have (User) ...

Loading development environment (Rails 3.2.2)
irb(main):001:0> User.first
NameError: uninitialized constant User
    from (irb):1:in `evaluate'

What am I missing?  Where and how do I make my very minimalistic app recognize the model?

Please let me know the specific line(s) to make the rails console recognize the model as applicable to
my very minimal app, as I need to get into the rails internals way of how models are recognized/loaded.

Thanks in advance.

Last edited by vrn (2012-03-17 12:49:38)

Re: Probing Rails Internal as part of migrating a heavily customized App

What are you using for your db? It seems lie you'd also need the config/databse.yml file to store the connection settings for the db.

For example, when I called Lesson.first from one of my apps (lesson being one of my models), it initiated an SQL query
SELECT 'lessons'.* FROM 'lessons' LIMIT 1

My advice if you plan on going the route of forgoing any generators whatsoever would be to generate an app with "rails new projectname" like normal and compare with the app you're building to see what you need to include.

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? |