6 Dec 2014

Learning Ruby on Rails

As I have been managing the company website, I realised I have to learn basics of web development. Therefore, last weekend, I joined a two-day workshop by Codecourse, which was a great opportunity to practically learn how to code with Ruby on Rails. This is my work-in-progress web applications.

It was really worthwhile course; what I essentially learnt was following:
  • All the important setups for web application development: online console by Nitrous, html and CSS frameworks by Bootstrap, online application platform by Heroku, Static Maps API by Google maps, voice and SMS APIs by Nexmo,  some gems in Github, and online e-commerce platform by Stripe.
  • How to practically develop (1) a personal website, (2) a web app to record locations and display in the map, (3) a web app to send a SMS text message, (4) a web app to upload pictures and purchase an order online, and (5) a web app to post status updates. So basically they are what you do mostly online nowadays (i.e. Wordpress or blogging, Messenger, Instagram, Amazon, Twitter etc.).
  • While following instructions by the organiser and facing unexpected errors, essentially my learning was about how to identify an error (mostly typo or undefined class or method) and how to crack it mostly by yourself.
Nitrous' console image
The following is my personal memo on the very basics on Ruby on Rails so that I would not forget about it at all.
  • To create a new project, command 'rails new the_name_of_the_project'. After run 'cd mysite", type 'rails server' starts the server so that you can check your code updates in your browser.
  • application.html enables every page to contain the same code that is in the application.html.
  • To add a new page, (1) open the routes.rb file in the config folder, (2) open the static_pages_controller.rb in app/controllers/, and (3) create a new file under the static_page folder.
  • To use Bootscamp CSS, first you have to copy Bootstrap CDN to the application.html.erb.
  • After you install in Gemfile (c.f. gem is a function defined/developed by someone already, e.g. Devise: sign-in and sign-up/authentication), you have to stop the server (Ctrl+c) and then run the "bundle install" command to reflect the changes while.
  • To upload updated pages, command (1)"cd the_name_of_the_project", (2) "git add . ", (3) "git commit -m"Finished the project", (4)"git push heroku master".
  • To create a database, run 'rails generate scaffold the_name_of_database', followed by name and definition of each column. (e.g. 'rails generate scaffold location name:string address:string latitude:float longitude:float')

No comments:

Post a Comment