Welcome to part 2. Lets get going:
My Ruby on Rails III notes (cheat sheet – sort of):
I installed Rails for windows using the Rails Windows Installer (http://railsinstaller.org/) (which has everything you need in one file!).
Rails uses a huge number of plugins and gems (self-contained solutions to specific problems such as pagination and image upload).
A gem is like a custom solution to a email app or a twitter type app. Learn more about Gems here (http://rubylearning.com/blog/2010/12/14/ruby-gems-%E2%80%94-what-why-and-how/?-what-why-and-how/)
How to create a app on Rails III with the Rails console:
rails new first_app
bundle install (Do this after you edited the Gem file in your new Rails app to include whatever Gem you need creating e.g. gem ‘sqlite3′ ’1.3.2′, :require => ‘sqlite3′)
If you want to see how the app works type in:
rails server or just rails s
Now open your browser and go to Localhost:3000
Rails uses the model-view-controller (MVC) structure.
Git is like an online website for managing backing up and managing your app.
It’s used by everyone and supposedly essential so register and create.
The rails GIT commands:
git add .
git commit -m ‘first commit’
git status (NB!)
git remote add origin email@example.com:/first_app.git
git push origin master
git checkout -b modify-README
Switched to a new branch ‘modify-README’
git checkout master
Switched to branch ‘master’
git merge modify-README
git branch -d modify-README
Deleted branch modify-README (was 2c92bef).
It is important to note that Git commits are local, recorded only on the machine on which the commits occur.
This is in contrast to the popular open-source version control system called Subversion, in which a commit necessarily makes changes on a remote repository.
Git divides a Subversion-style commit into its two logical pieces: a local recording of the changes (
git commit) and a push of the changes up to a remote repository (
For deployment of your app you need a platform or host and it seems everyone uses Heroku – and it looks pretty cool + easy.
Rails commands for installing Heroku and updating your app:
gem install heroku
git push heroku master
heroku rename railstutorial
REpresentational State Transfer (REST)
If you read much about Ruby on Rails web development, you’ll see a lot of references to “REST”, which is an acronym for REpresentational State Transfer.
REST is an architectural style for developing distributed, networked systems and software applications such as the World Wide Web and web applications.
Although REST theory is rather abstract, in the context of Rails applications REST means that most application components (such as users and microposts)
are modeled as resources that can be created, read, updated, and deleted—operations that correspond both to the CRUD operations of relational databases and the four fundamental HTTP request methods: POST, GET, PUT, and DELETE.
Now Rails can create a User model structure using scaffolding. It really makes things simple (remember to understand first – then take shortcuts). The code for creating a scaffold is:
rails generate scaffold User name:string email:string
Enough for now. The app is coming nicely in real time. I am about to add action mailer and then use delayed job for the email reminder part.