Reputation:
I have a existing Database and I dont need to generate any models but I would like to have also the columns of the tables inside the activerecord model.
I don't like to check everytime the columns of my table. I just need some kind of a reference to the column. And it looks pretty wrong to me not having them in the model.
Right now my models looks like this:
class City < ActiveRecord::Base
self.table_name = "city"
end
Btw I am using rails 4.
Upvotes: 1
Views: 48
Reputation: 8065
You may like this gem https://github.com/ctran/annotate_models, where it annotate the structure of model from database table like below,
# == Schema Info
#
# Table name: line_items
#
# id :integer(11) not null, primary key
# quantity :integer(11) not null
# product_id :integer(11) not null
# unit_price :float
# order_id :integer(11)
class LineItem < ActiveRecord::Base
belongs_to :product
end
Upvotes: 1