Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to represent / persist information for a table which will contain a dynamic set of configurations
- create table app (id, name, desc)
- create table app_config (id, app_id, key, value)
- def change
- create_table :app_configs do |t|
- t.text :config
- t.integer :app_id
- t.timestamps
- end
- end
- class App < ActiveRecord::Base
- has_many :app_configs
- ...
- end
- class AppConfig < ActiveRecord::Base
- belongs_to :app
- ...
- end
- $ rails new testproject
- $ rails generate scaffold App name:string description:string
- $ rails generate scaffold AppConfig key:string value:string app:references
- $ rake db:migrate
- resources :apps do
- resources :app_configs
- end
Add Comment
Please, Sign In to add comment