reviewing the fields I have in a model in rails

Boaz

It seems like a silly question, but anyway:

I have a model with lets say 10-12 fields (columns) added in different migrations.
When I write code now (model, view, tests) I want to have a list of the column names.
Is there a good way to do so? (other than going to the DB manually and getting the column names)

It seems like an action the developer does quite often, or is it just me

user2503775

Simply use ActiveRecord::Base#column_names:

Model.column_names

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create a new model which have all fields of currently existing model

From Dev

Cannot have multiple model fields with same choices

From Dev

Rails - defining data fields in the model itself

From Dev

Rails : How to have different labels for multiple fields_for

From Dev

Rails query with delegate fields of a model

From Dev

Ruby on Rails - add fields from a Model on another Model's form

From Dev

Adding fields to a Rails model without saving them in the database in Rails

From Dev

Rails checking model to see if all fields are empty

From Dev

How do I have two fields for a choice?

From Dev

Rails can have several fields_for in a form?

From Dev

Can I have a model called "Transaction" in Rails?

From Dev

Rails - not letting model be updated if fields have certain values

From Dev

Choosing to have an attribute or model in rails

From Dev

How can I update particular fields of model with validation in Ruby on Rails?

From Dev

Rails ElasticSearch model with fields

From Dev

Viewing ActiveRecord model fields in Ruby on Rails

From Dev

Rails - defining data fields in the model itself

From Dev

Rails : How to have different labels for multiple fields_for

From Dev

How should I validate the presence of fields that create an instance that doesn't have a model?

From Dev

Rails 4.1 nested model form fields

From Dev

Ruby on Rails - add fields from a Model on another Model's form

From Dev

Rails checking model to see if all fields are empty

From Dev

Only show fields that have content in Ruby on Rails

From Dev

Rails can have several fields_for in a form?

From Dev

How can I update particular fields of model with validation in Ruby on Rails?

From Dev

Rails ElasticSearch model with fields

From Dev

I have a small registration Form with 4 fields

From Dev

Rails: Inserting into a table that does not have any model

From Dev

Django: Can i link 2 model fields instead of the model class?

Related Related

  1. 1

    Create a new model which have all fields of currently existing model

  2. 2

    Cannot have multiple model fields with same choices

  3. 3

    Rails - defining data fields in the model itself

  4. 4

    Rails : How to have different labels for multiple fields_for

  5. 5

    Rails query with delegate fields of a model

  6. 6

    Ruby on Rails - add fields from a Model on another Model's form

  7. 7

    Adding fields to a Rails model without saving them in the database in Rails

  8. 8

    Rails checking model to see if all fields are empty

  9. 9

    How do I have two fields for a choice?

  10. 10

    Rails can have several fields_for in a form?

  11. 11

    Can I have a model called "Transaction" in Rails?

  12. 12

    Rails - not letting model be updated if fields have certain values

  13. 13

    Choosing to have an attribute or model in rails

  14. 14

    How can I update particular fields of model with validation in Ruby on Rails?

  15. 15

    Rails ElasticSearch model with fields

  16. 16

    Viewing ActiveRecord model fields in Ruby on Rails

  17. 17

    Rails - defining data fields in the model itself

  18. 18

    Rails : How to have different labels for multiple fields_for

  19. 19

    How should I validate the presence of fields that create an instance that doesn't have a model?

  20. 20

    Rails 4.1 nested model form fields

  21. 21

    Ruby on Rails - add fields from a Model on another Model's form

  22. 22

    Rails checking model to see if all fields are empty

  23. 23

    Only show fields that have content in Ruby on Rails

  24. 24

    Rails can have several fields_for in a form?

  25. 25

    How can I update particular fields of model with validation in Ruby on Rails?

  26. 26

    Rails ElasticSearch model with fields

  27. 27

    I have a small registration Form with 4 fields

  28. 28

    Rails: Inserting into a table that does not have any model

  29. 29

    Django: Can i link 2 model fields instead of the model class?

HotTag

Archive