# When should you restart a ruby server?

**URL:** <https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496>\
**Category:** rubyonrails-talk\
**Created:** [May 18, 2008, 9:25am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496 "2008-05-18T09:25:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![soa\_dias](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@soa\_dias](https://discuss.rubyonrails.org/u/soa_dias)\
**Post date:** [May 18, 2008, 9:25am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/1 "2008-05-18T09:25:13Z")

</div>

Hello everyone,

While walking through AWDWR, Task D: Add a Dash of AJAX, I was initially unable to let the AJAX magic work. Hitting the Add to Cart button doesn't yield to any output on its own; I had to manually refresh the pages to witness the change. But when I tried to restart the ruby server, and load the application again, everything worked fine.

Any explanations to behavior mentioned above? Are there other instances in which you have to restart a ruby server?

Thanks!

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [May 18, 2008, 11:03am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/2 "2008-05-18T11:03:27Z")

</div>

Well you definitely need to restart the server if you make changes to environment.rb (and its friends like things in config/initializers and the per-environment files like development.rb), routes.rb and if you install change any plugins. Without knowing exactly what was happening its hard to say in your case.

Fred

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [May 18, 2008, 11:06am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/3 "2008-05-18T11:06:22Z")

</div>

Don't know what exactly happened in that chapter/task D that you mention. But as a general rule you have to restart the server whenever you make changes to the config files or include a new plugin.

---

<div class="post-metadata">

**Author:** ![soa\_dias](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@soa\_dias](https://discuss.rubyonrails.org/u/soa_dias)\
**Post date:** [May 18, 2008, 2:57pm UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/4 "2008-05-18T14:57:38Z")

</div>

Thanks for the tips, I'll keep those in mind. But I apparently did not alter any configuration files while coding the cart application, so its strikes me as odd that I had to restart the server in order to get my application working well. I was unclear before, so let me try to explain my situation more in detail.

I was working on section 9.2 of the book. It's the part wherein you modify the "Add to Cart" button to send an AJAX request instead of a normal HTTP Post request, by adding this code to the index.rhtml view:

\<% form\_remote\_tag :url =\> { :action =\> :add\_to\_cart, :id =\> product } do %\> \<%= submit\_tag "Add to Cart" %\> \<% end %\>

Then I followed these steps: &nbsp;&nbsp;--\> I enabled javascript libraries through the \<%= javascript\_include\_tag :defaults %\> &nbsp;&nbsp;--\> Then I disabled the browser refresh upon clicking the "Add to Cart" button by stopping the page from redirecting to the index display &nbsp;&nbsp;--\> Afterwards, I added app/views/store/add\_to\_cart.rjs with this code "page.replace\_html("cart" , :partial =\> "cart" , :object =\> @cart)". &nbsp;&nbsp;--\> I saved everything, hit the refresh button on the browser, then when i finally click on the "Add to Cart" button, nothing happens. The cart display on the side bar ought to display the product that I've chosen to add. Only after refreshing again do i see the cart updated with the correct information. Of course, everything would eventually work fine if i restart the server. But still, I wish to understand this behavior to further understand the rails framework. Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![soa\_dias](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@soa\_dias](https://discuss.rubyonrails.org/u/soa_dias)\
**Post date:** [May 19, 2008, 1:58am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/5 "2008-05-19T01:58:45Z")

</div>

And by the way, the development.log did report an error that shows something like this:

Processing StoreController#add\_to\_cart (for 127.0.0.1 at 2008-05-18 22:53:41) [POST] &nbsp;&nbsp;Session ID: 8f38baa3f8b1d03e8cc8716aec52bb3f &nbsp;&nbsp;Parameters: {"commit"=\>"Add to Cart", "action"=\>"add\_to\_cart", "id"=\>"2", "controller"=\>"store"} &nbsp;&nbsp;e[4;36;1mProduct Columns (0.016000)e[0m e[0;1mSHOW FIELDS FROM productse[0m &nbsp;&nbsp;e[4;35;1mProduct Load (0.015000)e[0m e[0mSELECT \* FROM products WHERE (products.id = 2) e[0m Rendering within layouts/store Rendering store/add\_to\_cart

ActionView::TemplateError (No such file or directory - ./script/../ config/../app/views/store/add\_to\_cart.rhtml) in app/views/store/ add\_to\_cart.rhtml:

&nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_view/base.rb:440:in `mtime' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_view/base.rb:440:in `compile\_template?' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_view/base.rb:317:in `compile_and_render_template' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_view/base.rb:301:in `render\_template' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_view/base.rb:260:in `render_file' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:806:in `render\_file' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/base.rb:711:in `render_with_no_layout' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/layout.rb:247:in `render\_without\_benchmark' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/benchmarking.rb:50:in `render' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/benchmarking.rb:50:in `render' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:1096:in `perform\_action\_without\_filters' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/filters.rb:632:in `call_filter' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:619:in `perform\_action\_without\_benchmark' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/benchmarking.rb:66:in `perform_action_without_rescue' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/benchmarking.rb:66:in `perform_action_without_rescue' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/rescue.rb:83:in `perform\_action' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/base.rb:430:in `send' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:430:in `process\_without\_filters' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/filters.rb:624:in `process_without_session_management_support' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/session_management.rb:114:in `process' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action\_controller/base.rb:330:in `process' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/ dispatcher.rb:41:in `dispatch' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel/rails.rb:78:in `process' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel/rails.rb:76:in `process' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:618:in `process\_client' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:617:in `each' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:617:in `process\_client' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:736:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:736:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:736:in `new' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:736:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:720:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:720:in `new' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel.rb:720:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel/configurator.rb:271:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel/configurator.rb:270:in `each' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel/configurator.rb:270:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ bin/mongrel\_rails:127:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ lib/mongrel/command.rb:211:in `run' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/ bin/mongrel\_rails:243 &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active\_support/dependencies.rb:488:in `load' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active_support/dependencies.rb:488:in `load' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active\_support/dependencies.rb:342:in `new_constants_in' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active_support/dependencies.rb:488:in `load' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/ commands/servers/mongrel.rb:60 &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/site\_ruby/1.8/rubygems/ custom\_require.rb:27:in `gem_original_require' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `require' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active\_support/dependencies.rb:495:in `require' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active_support/dependencies.rb:342:in `new\_constants\_in' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/ lib/active\_support/dependencies.rb:495:in `require' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/ commands/server.rb:39 &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `gem\_original\_require' &nbsp;&nbsp;&nbsp;&nbsp;I:/InstantRails/ruby/lib/ruby/site\_ruby/1.8/rubygems/ custom\_require.rb:27:in `require' &nbsp;&nbsp;&nbsp;&nbsp;script/server:3

Rendering I:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ actionpack-1.13.2/lib/action\_controller/templates/rescues/layout.rhtml (500 Internal Error)

---

<div class="post-metadata">

**Author:** ![radar](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/radar/32/604_2.png) [@radar](https://discuss.rubyonrails.org/u/radar)\
**Post date:** [May 19, 2008, 2:07am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/6 "2008-05-19T02:07:48Z")

</div>

That’s very unusual to have to restart your server for it to detect a new view file, especially if there was an action for it. I was going to point out that you weren’t using the Rails 2.0 file extensions too, before I realised you’re not using Rails 2.0.

---

<div class="post-metadata">

**Author:** ![Crash2burn](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@Crash2burn](https://discuss.rubyonrails.org/u/Crash2burn)\
**Post date:** [May 19, 2008, 2:41am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/7 "2008-05-19T02:41:27Z")

</div>

Actually I've run into this issue before also, seems to be limited to js views used for ajax, where rails doesn't seem to know its there until i restart the server. I have no idea why, and I have no idea under what conditions it happens, just wanted to say I've experienced it..

---

<div class="post-metadata">

**Author:** ![soa\_dias](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@soa\_dias](https://discuss.rubyonrails.org/u/soa_dias)\
**Post date:** [May 19, 2008, 4:54am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/8 "2008-05-19T04:54:00Z")

</div>

I see, my old version of rails is the culprit then. Thanks for that info. I didn't download the latest version of rails before because I thought that it might have deprecated some of the Rails 1.2 syntax used in the book. I guess I should just give it a try then. 🙂

---

<div class="post-metadata">

**Author:** ![radar](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/radar/32/604_2.png) [@radar](https://discuss.rubyonrails.org/u/radar)\
**Post date:** [May 19, 2008, 4:56am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/9 "2008-05-19T04:56:05Z")

</div>

The older version of rails may not be the culprit, I never said it definitely was. I was just musing that you were using an older version of Rails.

---

<div class="post-metadata">

**Author:** ![George\_Bailey](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@George\_Bailey](https://discuss.rubyonrails.org/u/George_Bailey)\
**Post date:** [May 19, 2008, 5:16am UTC](https://discuss.rubyonrails.org/t/when-should-you-restart-a-ruby-server/29496/10 "2008-05-19T05:16:38Z")

</div>

From the Troubleshooting section of that chapter:

"Some readers have reported that they have to stop and start their appli- cation to get the AJAX-based cart to work."
