ruby on rails - NameError: uninitialized constant after checking name with .classify -


i have table part of mountable blog engine in rails. table called lines_articles.

def change  create_table "lines_articles", force: true |t|   t.string   "title"   t.string   "sub_title"   t.text     "content"   t.boolean  "published",        default: false   t.datetime "published_at"   t.string   "hero_image"   t.datetime "created_at",                       null: false   t.datetime "updated_at",                       null: false   t.string   "slug"   t.string   "gplus_url"   t.boolean  "featured",         default: false   t.string   "document"   t.string   "short_hero_image" end 

i want show contents in table in rails console, ran .classify make sure didn't screw plural variable, , output was:

 2.2.1 :015 > "lines_articles".classify    => "linesarticle"  

so console confirmed naming convention, when run simple linesarticle.all, error: nameerror: uninitialized constant linesarticle.

how can console classify table name , throw nameerror when querying table name?

you have define model class in app/models/lines_article.rb directory.

if you're on rails 5, should this:

class linesarticle < applicationrecord end 

if you're on rails 4, should this:

class linesarticle < activerecord::base end 

then re-open rails console , try again.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -