In Rails console when I write Something like:
City.human_attribute_name("model") it's work correctly, a return value, but when I try to use it in .haml in Options_from_collection_for_select I have error.
= select_tag("select_tag", options_from_collection_for_select(@searchesForSelectTag, "name", 'human_attribute_name("model")', params[:select_tag]), {:include_blank => ' '})
NoMethodError: undefined method `human_attribute_name("model")' for #<Class:0x00007fdb90dd1198> Did you mean? human_attribute_name
@searchesForSelectTag - this is array of classes name (eg. User, City, Car...).
When I try like only that : "human_attribute_name" I have ArgumentError:
wrong number of arguments (given 0, expected 1..2)
How can I add argument "model" to method human_attribute_name in Options_from_collection_for_select ?
Instead of a string, you can pass a method call on a class:
Update
I found another solution with dynamic classes. You can try to experiment something with this.