0

I have created a seed file, ran rake db:migrate and rake db:seed everything seemed to have run fine. However, I would now like to view the seeds in rails console, the name of the table is usersinfo. How do I view to verify that the seeds populated correctly in console?

I have tried usersinfo.all in console but got the following error.

undefined method `all'

FluxEngine
  • 12,730
  • 14
  • 57
  • 83

3 Answers3

2

As far as I know, you cannot directly view tables from rails console, however you can check if the table has data via the associated ActiveRecord model of that table

Ex:

if your table name is usersinfo You should probably have a model called

class Userinfo < ActiveRecord::Base
  set_table_name :usersinfo
end

and then in console you could do

Userinfo.all

NOTE: as per the rails convention, your table name should be plural, If you are not using the rails convention, you could always set the table name via set_table_name: method

and also, .all is a ActiveRecord class methods and works only with an Activerecord Model

sameera207
  • 16,547
  • 19
  • 87
  • 152
1

You have to call .all method for your model.

Userinfo.all

I would recommend you to read the Active Record Query Interface

ck3g
  • 5,829
  • 3
  • 32
  • 52
0

Had a similar problem. This did the trick for me:

rails runner 'p Userinfo.pluck :column_name`
Luke
  • 11
  • 1