What is the complexity of active record Model.columns
or Model.column_names
operation on rails?
Basically I have an option of either hard coding it like that:
do_something(:column_name1)
do_something(:column_name2)
do_something(:column_name3)
or I can do that as following:
columns = Model.columns
columns.each do |c|
do_something(c.name)
end
I want to use the second one, because I have to do that in couple of models and if I choose the second option it saves me time and lines of code. But I am thinking if I had to face any time penalty at run time or not?
Also posted on stackoverflow: http://stackoverflow.com/questions/33273311/what-is-the-complexity-of-model-columns-or-model-column-names-on-rails