CS6320:  SW Engineering of Web Based Systems

 

Ruby on Rails Tips

 

Finding out list of gems (including rails) and version numbers installed on your machine

cmd window > gem list --local

Running Rails Locally --- typically runs at http://127.0.0.1:3000 (port 3000) OR http://localhost:3000

After you hit RUN in your IDE, then you go to a browser and type in http://127.0.0.1:3000/YOURAPP_PATH_URI

WHY above do you not see your application& only see the webpage in previous image--> because you need to specify a ROUTE from a URI to the appropriate Controller in your app

Install

  • You should make the Ruby*/bin directory from your ruby install part of your computer's PATH environment variable.

  • Sometimes you will need to install different gems (gem install gema_name) to get rails to work or your IDE.

Install Problem:

Problem: When executing gem install rails get following error (SSL issue)

ERROR:  Could not find a valid gem 'rails' (= 3.2.13), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect SYSCA
LL returned=5 errno=0 state=SSLv2/v3 read server hello A (https://rubygems.org/s pecs.4.8.gz)
ERROR: Possible alternatives: rails

 

 

Solution: (found on internet--- add http site rather than default https to get around SSL problem).

gem sources -a http://rubygems.org

then answer y for

Do you want to add this insecure source? [yn]

lastly,

gem install rails

hope that helps :)

 

 

When Running (especially windows get error = No source of timezone data could be found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error.)

 

solution from this website is:
1) run following in console window to install a gem= gem install tzinfo-data

2) go to directory of project and edit the GemFile and add the lines

#adding gem for tzinfo-data
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]


 

Adding a column to a database table after created model

You want to open your console and run the following command your after is rails g migration add_column_name_to_table column_name:type then run a bundle exec rake rake db:migrate

here is an example where adding the column to the Model User and then performing a migration

results

 

© Lynne Grewe