I was tasked with creating a simple shopping website demo. I decided to use Ruby on Rails because it is in demand, easy to use and I would be learning something new. So what is Ruby on Rails? It is a server-side web application (MVC – model-view-controller) framework. Ruby is the language. Models map to your database, controllers handle requests and views display information in the browser.
First thing I did was download and install this bundle. After installation I would get the following error message when running the rails command, “Error message – The system cannot find the path specified.” I found out that the bundle and bundler batch files contained a bug and needed to be edited as indicated here.
Another error I encountered was, “Most likely your system doesn’t have the CA certificates needed for verification. For information about OpenSSL certificates, see http://bit.ly/ruby-ssl.” This link helps with that error. I added the system variable permanently through control panel.
Finally I could start creating an app. A new app consists of standard folders and files. After creating the app and starting the server I can access the app from localhost:3000 where a placeholder shows. This link is a useful place to get started. My text editor of choice is TextPad. You can create very basic CRUD functionality by using the scaffold option. The default DBMS is sqlite3 and you can use the command “rails dbconsole” to access a prompt for SQL commands.
After I used scaffold I was getting the following error
ExecJS::ProgramError in Products#new
C:/Sites/myapp/app/views/layouts/application.html.erb where line #5 raised:
TypeError: Object doesn’t support this property or method
I found out that one way to fix this error is to install node.js and that it results from “incompatibility between 64bit Windows and the CoffeeScript gem.”
Development is made easier with a good IDE and proper DBMS. I searched and found that NetBeans (with RoR plugin) is a good free option. A good paid option is RubyMine. Netbeans links to the Ruby on Rails plugin but says it is unsigned and untrusted during installation. This doesn’t make sense to me. During installation I was prompted to install warbler. After creating my app and hitting run I get the following error, “C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe: No such file or directory — script/rails (LoadError).” I found out that a workaround for this is to create the script folder (in the project folder) and copy files from the bin folder. Be careful of switching between the IDE and command line. They may be setup differently and this could create a conflict.
Gems, templates and engines can be used to create powerful apps quickly. I feel comfortable using Ruby on Rails and was able to get started in a short space of time. Next steps will be completing the app and taking a few online courses as needed. Please share your thoughts and experiences in the comments below.