-1

I was wondering is there a way to show the hash map array? I'm not sure if its the right terminology? But I wanted to see the columns from the database to see if I'm calling the correct hash keys.

For instance,

created on <%= link_to activity.trackable.list.name, activity.trackable.list %>

I'm not sure if I'm calling the correct names, if I'm getting undefined method? If I need to see if there's a key for .name or .list. I would like to see the array of activity.trackable if there's such thing?

This code is coming from a tutorial in rails cast #407

hellomello
  • 8,219
  • 39
  • 151
  • 297

2 Answers2

0

You could do something like:

p activity.trackable.columns

or

p activity.trackable.columns_hash

or

p activity.trackable.column_names

if you want to see more, you could do

p activity.trackable.methods

or

p activity.trackable.respond_to?( :something )
Brad Werth
  • 17,411
  • 10
  • 63
  • 88
0

I recommend installing the awesome_print gem

then in rails console you can inspect objects easily

ap activity.trackable

# or

ap Activity.new

see

OR if you are using postgres you can do

psql your_db_development -c "\d activities"

# lists all columns on database table and their types
house9
  • 20,359
  • 8
  • 55
  • 61