Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6886163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:43:30+00:00 2026-05-27T05:43:30+00:00

I just discovered the rails-settings gem and now I need to make an admin

  • 0

I just discovered the rails-settings gem and now I need to make an admin page that lets me edit the setting values. How would I make a settings controller with an edit view that can change these dynamic app wide settings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:43:31+00:00Added an answer on May 27, 2026 at 5:43 am

    I haven’t used this gem but it seems like it should be fairly straight forward. Since it uses a database backed model, you would simply create a controller as normal:

    rails g controller Settings
    

    From here you would define your index action to gather all your individual settings for display in the view:

    def index
      @settings = Settings.all
    end
    

    Then in the view you can setup a loop to display them:

    <% @settings.each do |setting| %>
      <%= setting.var %> = <%= setting.value %>
    <% end %>
    

    As far as editing … this might be a bit tricky since by default rails would expect you to submit only one setting at a time to edit. You could do it this way but unless you implement the edit with ajax it might be tedious and non-intuitive.

    Another way would be to set up your update method to accept all the individual settings at once, loop through and update each one with new values. It might look something like this:

    // The /settings route would need to be setup manually since it is without an id (the default)
    <%= form_tag("/settings", :method => "put") do %>
      <% @settings.each do |setting| %>
        <%= label_tag(setting.var, setting.var) %>
        <%= text_field_tag(setting.var, :value => setting.value) %>
      <% end %>
      <%= submit_tag("Save Changes") %>
    <% end %>
    

    This should output all of the settings (given they have been assigned to the @settings variable) with the var name as the label and the current value as the text field value. Assuming that the routing is setup, when you submit this form the action that receives it should all the new settings in the params variable. Then you can do something like this in the action:

    def update
      params.each_pair do |setting, value|
        eval("Settings.#{setting} = #{value}")
      end
      redirect_to settings_path, :notice => 'Settings updated' # Redirect to the settings index
    end
    

    This may not be the best way depending on how often you edit the settings and how many settings you have…but this is a possible solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just discovered the Cane gem but it doesn't work with Rails, there is
I just discovered that truncate {table} statements are not caught by most database triggers.
i just discovered http://code.google.com/p/re2 , a promising library that uses a long-neglected way (
I just discovered this component and started working with it. I understand that the
I just discovered that the caps lock and shift key (and probably some more
I just discovered that Except() will remove all elements in the second list from
I just discovered when creating some CRUD tests that you can't set data in
I just discovered tabbar , a minor mode that provides firefox like tabs in
I just discovered that if I do the following: Click the button that animates
I've just discovered that when the remove() function is used, the matched elements are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.