Please Login to Continue

Free Software Development Articles.Email List

Advertise Here

CSS not rendering in Ruby on Rails [Development Notes]

When Ruby on Rails does not render CSS and Images look disproportionate on Linux Ubuntu Destro (Windows Subsystem) try the following below:

problem: If you're developing Ruby on Rails on Windows Linux Sub System, Windows might block port 3012 or you might get an error like below, this will force you to start Rails Server on a different port that might break the Ruby Assets Pipeline from getting requested since the Asset_Host might be hardcoded to request on a different port.

/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/binder.rb:273:in `initialize': Permission denied - bind(2) for "" port 3014 (Errno::EACCES)
  1. Make sure no other apps like VS Code or Git Client are using the same [Web App directory] where the website is located because one process can lock the other. 
  2. Before running any commands in your project directory using your favourite Console App (e.g. Powershell, CMD, Bash etc), Open up Development Tools and navigate to Network Tab. On Network tab click "All" to see all static files being requested from the Server and examine those that show in "Red" or says "Fail". Then click on one of the failed files and examine the "Header" section of the section opened. This is an important step, verify that the port that shows next to localhost:(port number) matches with the port number you started Rails Server on. If not, that is where the problem is. To Fix this, Stop the Rails Server by pressing Ctrl + C (If pressing Ctrl + C) does not stop the Rails Server then kill Puma Process with this command (pkill -9 -f puma) make sure you are in a website directory for these commands to work.
    - After the Rails Server has been stopped, Start the Rails Server on a port you saw in the Development Tools e.g localhost:3012 by typing this command: rails s -p 3012  
    - Your problem should be solved. If not, then proceed to the rest of the list.
  3. Open up Bash or your favorite Console App and navigate to the folder where the website is located and run:
    - sudo bundle update
    -After the installation or updates are installed try to run the Rails Server by typing: Rails s which starts the server on port 3000
    - Sometimes starting the server on default port does not work, in this case, proceed to number 3.
  4. If number 2 did not work, try starting the Rails Server on a different port like so: rails s -p 3001
  5. If number 3 does not work, observe the logs and pinpoint what the error seems to be and start troubleshooting from there.
[NB]         [Working Solution: Another Option that Works]
6. Go to your project folder, if you are using VS Code IDE and Search for "asset_host"
   - There is a big chance that the URL for requesting Assets is hard-coded under development.rb found in: config = environments = development.rb 
     - Change the config.action_controller.asset_host = "http://localhost:PortNumberYouAreRunningRailsAppOn"
Technology published
Buy Me Coffee

Was this page helpful?

Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful..

© 2020 - ErnesTech - Privacy