This question is about ruby on rails. What is the way to get the list of all keys that I can pass to a ruby on rails model's constructor? post.attributes method gives me the list of all actual columns in that table. But it doesn't include fields generated by associations. It would not include :blog. How can I attributes plus fields created by association? Thanks.
Asked
Active
Viewed 113 times
0
user2026920
- 27
- 5
1 Answers
0
There are many ways to check the attributes of Model:
Model=> return Model fields with their datatypeModel.new=> return Model fields with their default valuesModel.inspect=> returnstringof Model fields with their datatypeModel.attribute_names=> returns array of attributesModel.column_names=> returns array of attributesModel.new.attributes=> return hash of all fields with default values
puneet18
- 4,341
- 2
- 21
- 27