Closed Florent2 closed 13 years ago
How about (notice the splat argument)
attributes *MyModel.column_names.map(&:to_sym)
or
MyModel.column_names.map(&:to_sym).each { |a| attribute a }
Thanks Nathan! The splat argument is the solution.
Any chance this kind of functionality would be pushed into RABL? Such as an all_attributes
method?
But RABL is not tied to an ORM or any object expectation. So what would all_attributes
do that would work across all objects? I would recommend just creating your own helper and using that.
Ah, right. My mistake for only thinking in the context of Rails.
Just for the record the map(&:to_sym) is not necessary. *MyModel.column_names
works just fine.
Hi,
In a particular rabl view, I want to declare all the attributes of a model. I tried
but I get ActionView::Template::Error error:
Is it possible with rabl to not have to manually list the model attributes?
Thanks :)