Follow Along as I Stumble on the Path to Learning RoR

Posts tagged “error

Showing Errors in the Logs

I had some errors occurring in my controller, but it wasn’t displaying in my views.  So I had to figure out how to see what was happening since I didn’t see any messages in the logs that were helpful either.

I found the solution in one of the answers here on Stack Overflow.

By adding this to my controller (it was the creation of a model – @user):

logger.warn("====error==========#{@user.error.full_messages.inspect}============")

This recorded the error in my logs (one of my model validations needed to be changed).

Advertisements

The plain HTTP request was sent to HTTPS port

I was receiving the error “The plain HTTP request was sent to HTTPS port” error”, Nginx error 400.  The problem was a an Nginx configuration error.  I found the solution in this StackOverflow question.  In the config file with your server info (mine was in /etc/nginx/sites-enabled/default):

make these changes:

listen 80;
  listen 443 default ssl;

  # ssl on   - remember to comment this out

 


Creating a CSR on Windows

In order to create a SSL Certificate, you need to generate a CSR, or Certificate Signing Request.  I ran into some issues when generating one from Windows, so I wanted to document the steps that I took.

  1. went to http://slproweb.com/products/Win32OpenSSL.html to download Win32 OpenSSL v1.0.0k
  2. installed OpenSSL
  3. I received an error regarding C++ during the install, so I installed Visual C++ 2008 Redistributables from the same page I downloaded OpenSSL
  4. Run a command prompt (cmd.exe from the search box in the Windows start menu)
  5. When I tried to run an OpenSSL command, I received an error that a file could not be found (WARNING: CAN’T OPEN CONFIG FILE: /USR/LOCAL/SSL/OPENSSL.CNF)
  6. As noted here, you have to set the environmental variable by typing this into the cmd: set OPENSSL_CONF=c:\[PATH TO YOUR OPENSSL DIRECTORY]\bin\openssl.cfg
  7. navigate to the bin directory
  8. enter your openssl command to generate your csr.  For me, it was:
    openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out myserver.csr
  9. this created key and csr files I could use for creating my SSL certificate

Error From Coffee Files

When I had to set up a new Windows PC with Rails, I ran in to a mysterious error where I couldn’t view my app because of purported problems with my .coffee.js files.  However, I knew there was no issue with the files since they were created during scaffolding and had only comments in them.  Furthermore, I was able to run the same code on my other PC fine, as is.

When I viewed the –trace there was nothing of note (except listing that the coffee files had issues with them).  When I tried to load the view, I did see this though “ExecJS::RuntimeError in Home#index”

Fortunately, I found the solution in this thread which explains that this is the result of Node.js not on a PC, or the path not set correctly in Windows environment variables.  I downloaded the Windows installer (.msi) file and installed Node.js and added the path to the PATH environment variable.  After I restarted my Rails server, the error went away.


Creating a Manifest.json file for the Google Chrome Store in Windows

I ran into an issue with my manifest.json file when trying to submit my app to the Google Chrome Store.  I followed the directions, but apparently there was a detail that was so simple, it wasn’t documented.  The documentation says to create a text file to put the manifest code, and then to save it as manifest.json.  However, when I loaded my zip file, I kept receiving error messages saying that the manifest.json was not at the root level and couldn’t be found.  The only thing was the file was of course there, and there were no subdirectories in my zip file.

It turned out to be a stupid, basic mistake.

When I looked at the properties of the file, the file was a .txt file, and the full name was actually manifest.json.text even though I couldn’t see the .txt part in Windows Explorer.  I found the solution was that when the file was created, I should have named it manifest.json, but also when I saved it in Notepad, I should have selected “Save as type” as “All Files”.  When you look at the properties, the file type will now be “json” instead of “txt”.


ActiveAdmin Translation Missing Error

I was receiving a translation missing message that was showing up on my page views for my ActiveAdmin page.  To correct this, I found the solution on Stack Overflow which said that these translations were just missing from my en.yml file in locales, and to replace my existing one with the one here (that ActiveAdmin uses):

https://github.com/gregbell/active_admin/blob/master/lib/active_admin/locales/en.yml


Rails Paperclip Error: identify ‘-format’ ‘%wx%h’

I was receiving the “identify ‘-format’ ‘%wx%h’ ” error with Paperclip.  The reason is because Paperclip requires ImageMagick if images are manipulated, and the path must be specified for this to happen.  In order to find the path in Windows, what I did was:

  1. open a command prompt (CMD from the start menu)
  2. navigate to c://
  3. type “PATH”
  4. it should show the path(s) that can be used for ImageMagick
  5. I added this line to development.rb

Paperclip.options[:command_path] = “/bin” #(in place of “/bin” put your path)

Restart your server.