Topic: If I make a mistake on system setting and my site is down, how do I reset it?

Topic type:

This goes through the steps to fixing a system setting's value when you have put in a value with the wrong syntax.

Let's say you didn't put things in correctly when following this guide:

http://old.kete.net.nz/site/topics/show/333-how-do-i-make-it-so-new-registrants-automatically-become-members-of-a-basket-besides-the-site-basket

and your site comes up with an error on every page!

You get something like this (amongst a big scary error page):

 

Error message:
(eval):1:in `constant_value': compile error (eval):1: syntax error, unexpected ',', expecting $end [1],[10] ^
Exception class:
SyntaxError

 

In this case you probably forgot to add a comma.  How do you update this system setting when the site is down?

The answer is that you need to use the "console" from the "command line" on your server. This guide has more information on the console, but here are the rough steps (helpful comments will be preceded by a #, these can be left off the actual command)  :

  1. open a shell on the host in question and navigate to your application's home directory
  2. open an irb console session like so (drop "production" if the site is running in development mode)
    $ script/console production
    >> setting = SystemSetting.find_by_name("DEFAULT_BASKET_IDS") # this is the name in our example, you may need to adjust what are in quotes for your case
    >> puts setting.value # inspect the value to see what is wrong
    >> setting.value = "[1,2,3]" # put in the correct value in the right syntax here!!!!!
    >> setting.save!
    >> quit
    $ touch tmp/restart.txt # this restarts your server, test the site is ok now
    

Discuss This Topic

There are 0 comments in this discussion.

join this discussion

Creative Commons Attribution-Share Alike 3.0 New Zealand License
If I make a mistake on system setting and my site is down, how do I reset it? by Walter McGinnis is licensed under a Creative Commons Attribution-Share Alike 3.0 New Zealand License