On Nov 24, 5:17 am, Thufir <[email protected]> wrote:

> Ah, that might very well be the problem -- it's not a rails app per
> se, just AR at this stage.  I'll probably add rails to it, but may add
> a ruby FOX (?) GUI as well or instead.

Does that mean that ActiveSupport::Dependencies.load_paths is not
configured ? (if you're not loading rails itself and you're not doing
this explicity then the answer is no). What the setting does is tell
ActiveSupport where to look for files when it needs to find a not yet
loaded class.

>
> > And on my item 2 above, it's generally bad ju-ju to depend on the
> > external definition of model classes within migrations.  Instead you
> > should create the inside:
>
> Ok, this is the crux of the issue and the solution for my particular
> road block :)
>
> >   class CreateUrls < ActiveRecord::Migration
> >         class Url < ActiveRecord::Base
> >         end
>
> What I did was to add:   require 'url'
> and that fixed the problem.  Although, it's black magic, to me, as to
> how ruby found the correct Url class, but "works for now."  I don't
> like the way the model is defined in multiple places as shown above.
> However, please make your case on the bad ju-ju!  It's more
> conventional to define the model in the migration?
>

Yes. The problem with using the external definition of the model is
that when you deploy your code, the code all gets deployed in one go,
but your migrations get run one by one. For example, in migration 3
you might decide to add a new column to Url and add a validation on
that column. Now if you deployed your code and tried to run migration
1 it would fail, because even though the database does not yet have
that column Rails would still try to run a validation against it.

Fred

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to