I need an array with the column names of a table
Any ideas how I can do this with rails 3.0.0rc?
create a model:
$ rails g model Post title:string body:string
verify app/models/post.rb
class Post < ActiveRecord::Base
end
from your terminal:
$ rake db:migrate
$ rails c
> Post.column_names
should produce:
=> ["id", "title", "body", "created_at", "updated_at"]
credit to @dombesz's comment in Andrea Pavoni's answer