Server does not show recent changes - ruby-on-rails

I'm developing a Ruby on Rails project related to semantic technology, and I'm making something basic that allow the uploading of files and searching in those files.
So far it's all working out ok, but I have noticed that when I make changes to my code files or haml files, I don't see those changes on the webserver. Only after either rebooting the server or mashing the F5 button like crazy, the changes come through. And even that is not guaranteed.
The server is running on a local, virtual, ubuntu system. This is an Apache2 webserver configured with Passenger. The website is visibile, it's just not always the latest changes.
Anyone have an idea what might be causing this, or how I can fix this?

In your config/environments/environment_name.rb file it's likely that you have these lines:
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
Which you can switch to have the behavior you want.
If you don't want to change these then you can just touch tmp/restart, which will push the changes through (it's quicker and more graceful then restarting the web server)
To change the environment passenger runs in add the following line to your vhost:
RailsEnv development

Related

First request to rails app extremely slow

The first request to my rails app is extremely slow in all environments.
This should not be due different way of caching/loading gems. It was fine two hours ago and no major changes are made.
What I did the hours before I noticed my app turned slow:
I messed around in production.rb (NOT in development.rb): I was playing around with config.serve_static_assets = true
I did a bunch of tasks to diagnose why asset pipeline did not load my stylesheets and images in production (like rake assets:precompile RAILS_ENV=production and rake:clean assets:precompile).
Afterwards I obviously tried to undo all the changes I made, but for some reason my app is now slow in development, while it was perfectly fine before.
How can I fix this?
Thanks in advance :-)
UPDATE 1
When I send a request for localhost:3000, only after 12-13 seconds I receive:
Started GET "/" for ::1 at random time
Rendering behaving is normal. All requests after the first one are fine.
UPDATE 2
In an older version of my application I did the following:
Replace the old 'app'-folder with the newer one
Replace the old 'db'-files with the newer one
Replace the old 'config'-files with the newer one
Everything is running smoothly and still have no clue as to what was wrong in the first place. Please note that the version of the app from yesterday still runs slow, so this is not a non-rails related issue.
Answer
In production on localhost somehow my assets aren't served up (while they do appear in the public directory after a precompile).
In production.rb:
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
was changed to:
config.serve_static_files = true or even
config.serve_static_assets = true.
This also slows the first request down in a development environment apparently
I have this problem too, and i found bottleneck.
Problem in realization OpenSSL::Random.random_bytes on Windows (see this: https://github.com/rails/rails/issues/25805). It used for cookies.
I wrote this solution for my debug machine. But this is very dangerous and not must be used in production
module OpenSSL
module Random
def self.random_bytes(length)
::Random.new.bytes(length)
end
end
end

Dockerized Rails 5 RC1 application not picking up updates to controllers and models in development

I have quite a bit of experience developing Rails 4 apps on Mac OS X + Docker Machine + Docker Compose, but something has changed with how Rails 5 is caching files in the development environment (currently testing with RC1).
After starting the application with docker-compose up, the application runs normally in development mode.
But if I make a change to a controller or model, the only way I can get that reflected in the application is to stop the server and start it back up.
So now my workflow looks something like this when I need to make a change to a controller or model:
Make change to controller/model class.
Stop server with Ctrl + C.
Start server back up with docker-compose up.
Wait on the server to start up.
Run whatever I was running in the browser.
To say the least, needing to do steps 2-4 is annoying and not what I'm accustomed to from Rails 4.
I went a step further and uninstalled Spring using the Removal instructions, but I still get the same behavior.
I also searched for any settings that I could find in config/environments/development.rb related to the Rails runtime's iron grip on the model and controller classes, and I couldn't find anything. (I assume that it really wants to rely on watching the filesystem in order to selectively load changes, and something isn't being picked up from a change on Mac to VirtualBox.)
Any other ideas on what I can try? Or are there any new settings related to how this more aggressive caching works?
I'm Using Rails 5 rc1.
Rails 5 introduced some "improvements" to code reloading, but it doesn’t seem to work with Docker on OS X.
So in config/environments/development.rb, I replaced
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
with
config.file_watcher = ActiveSupport::FileUpdateChecker
It seems that for the ActiveSupport::EventedFileUpdateChecker file watcher, the change event does not occur for docker-machine shared files

Rails not reloading classes

I have a rails app in development mode that is not reloading any model/controller classes upon modifying the files unless the dev server is reset. The same exact project used to reload the files fine but without any apparent changes it is no longer working.
I have config.cache_classes = false set in my development.rb file. I have also confirmed that I am running in development mode. I have went as far as printing the cache_classes variable out to the screen with the server running to confirm it is false, which it is.
I am not running in threadsafe mode, I read this can mess the the cache_classes setting.
I have also confirmed that the timestamps on the files are being updated when I save them. I am running Rails 3.2.13. I have the same result when using either webrick or pow. What could be causing the classes to not being reloaded?

How did this Ruby on Rails app get deployed?

I have a Ruby on Rails app running on my server, and I can't figure out how it was deployed (someone else set it up).
The app is located in /var/www/myapp. Before it was deployed, I had been able to go in there and make minor edits to the app. The person helping me out with RoR then "deployed" it. It was unclear what deploying actually did, since it points to the same database and is on the same server. However, I can no longer edit it (or at least, the files I am editing are not being pointed to by the server).
Any way to figure out how this thing was deployed so I can take it down to edit it? Or should I basically just start over?
Was it maybe running in development mode before, and now it's in production? When it's in development mode, all of the files are loaded on each request, so your changes show up immediately. In production mode, you have to restart the server to see your changes.

Why don't my views update?

I'm new to Ruby on Rails and am creating a test application. So far, it's working, but when I make some minor changes to my views, the page doesn't change.
My problem may be related to this question, but I'm not sure what is meant by setting the date and time in the VM. My code is on a remotely hosted server, so I assume it would use the system time of that machine.
Is there a caching issue here? What can I do about it?
If you don't have control over the server environment yourself (no shell access, etc.), you can set the following at the top of config/environment.rb:
ENV['RAILS_ENV'] = 'development'
Development doesn't cache much, so while it's slower it's much nicer to develop in.
You'll still need to restart your app after making changes to anything outside the app/ folder though (configs, plugins, etc.).
You need to restart your Rails app (or Apache if you are using Passenger) if you are in production mode!

Resources