R – In Rails, is there an easy way to check out the attributes of an ActiveRecord

ruby-on-rails

I'm aware that I can check an ActiveRecord through the rails console but it shows the entire output in one line. This can be an issue to look up a specific attribute if the table has many columns.

>> Story
=> Story(id: integer, name: string, link: string, created_at: datetime, updated_at: datetime)

I like how the attributes are displayed in the create migration files but if I have many migration files, it might be a bit hard to track the one that I want.

In Django, I can go straight to the models.py and check the attributes for any models I want. How do Rails developers do this kind of lookup?

Best Answer

config/schema.rb has the db schema, and in other words all the attributes. I just open the file and search for "posts" for a Post model, and so on.

Related Topic