开发者

Generate migrations and migrate through browser

Are there any rails gems or engines that would allow you to add columns to a database through the browser rather than the standard way of generating migrations through the console?

Basically, something that would be similar to phpmyadmin for php, but just very simple to add and remove columns. This is for a CMS I am working开发者_如何学运维 on that would allow users to add custom fields. If anyone can point me in the right direction.

Edit:

I was hoping I could use something like the following in a model to add a new column, but it doesn't work:

 def add_test_column
   add_column :my_table_name, :test_column_name, :string
 end

Is it even posible to use the AR methods like add_column, add_index, etc. in my models?


I see now that you can add columns and handle the other migration actions within a model with:

def self.add_column(name, type, args= {})
    ActiveRecord::Migration.add_column table_name, name, type, args
end

from: similar question

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜