-3

I have a model called configurations which holds key value pairs in my database to store options for the website. The schema looks like this:

create_table "configuration", force: :cascade do |t|
  t.string "key",   limit: 255
  t.string "value", limit: 255
end

I would like to create a page in the website, so as an admin, I can edit the values on the configurations without the need to enter the database and change them manually.

However some of the values are strings, some are integers and some are Boolean, and I would like that to be reflected in the page, so a particular key might have a drop down of true/false for a Boolean value or a text box for a string etc.

Would this be possible, and if so, how do I write a controller/form to implement this please?

1 Answers1

-1

You can do above by standard Scaffold

rails g scaffold Configuration key:string value:string

then execute rake db:migrate

& allow this page only for admin

Scaffold will generate rails standard model, view & controller for the same.

Chakreshwar Sharma
  • 2,571
  • 1
  • 11
  • 35