legacy db - uninitialized constant

10 views
Skip to first unread message

tom

unread,
Nov 24, 2015, 11:30:28 AM11/24/15
to Ruby on Rails: Talk
hi, im doing a conversion and im stuck here:

class GLEntryVatEntrylink < ActiveRecord::Base
    self.table_name = 'G_LEntry-VATEntrylink'
end


>>
1.9.3-p194 :001 > GLEntryVatEntrylink.all
NameError: uninitialized constant GLEntryVatEntrylink
        from (irb):1



whats wrong here?


thx




Colin Law

unread,
Nov 24, 2015, 12:29:25 PM11/24/15
to Ruby on Rails: Talk
Are you using irb or
rails c

If irb then try rails c. irb does not automatically load the rails
context. Otherwise what is the filename for the class? Also have you
created the table (though not sure that would give that error)?

Colin

tom

unread,
Nov 24, 2015, 12:32:57 PM11/24/15
to Ruby on Rails: Talk
yes thats the console.
the file name is called: g_l_entry_vat_entrylink.rb


thx




Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs%3DiubEGLE3X%2BMe8Y_%2Brb%3DfGtk5JhUmEL3Yzi3sMBC4BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Nov 24, 2015, 3:52:57 PM11/24/15
to Ruby on Rails: Talk
On 24 November 2015 at 17:32, tom <toma...@gmail.com> wrote:
> yes thats the console.
> the file name is called: g_l_entry_vat_entrylink.rb

I notice that (for rails 4.2.5 at least) that
'GLEntryVatEntrylink'.tableize gives "gl_entry_vat_entrylinks". I
wonder whether that means the file should be called
gl_entry_vat_entrylink.rb. If that doesn't work then in
config/application.rb try

config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**/}')]

which I think will force it to load all model files whether the names
match the classes or not. Just make sure you do not have any
non-model files there (backups from editor or whatever).

Colin
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMf%2BS_zcMm5yQgurLWy_GgVUCevguUvhOFHotMvtJty_kA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages