Chapter 2 Flashcards
create new rails app(all of its directories generated)
cd workspace
rails 4.2.2 new toy_app
cd toy_app
$ bundle install –without production
flag prevents local installation of any production gems
what must you do after you made changes to the gem file
run bundle install
put rails app under version control
git init
git add -A
git commit -m “Initialize repository”
pushing rails app after putting app under version control:
git remote add origin https://github.com/saweel/toy_app.git
git push -u origin master
(must create repository manually in github and then push it into it (thats what she said))
typical first step when making a web application:
create data model, represenation of the structures needed by out application. in toy app, microblog, with only users and short posts. model for users and then model for microposts
data model for a user
interger identifier (id), name (string), email (string)
model for micropost
id (integer) and content text (string), we want to associate each post with a user, so we need user_id (integer) for the post
user resource:
allow us to think users as objects that can be created, read, updated, and deleted through the web via the HTTP protocol. generage it using scaffold
use scaffold command to generate a resource (user) with parameters for attributed: name and email of type string. why dont you need to include id?
$ rails generate scaffold User name:string email:string. no need to include parameter for id; it is created automatically by rails for use as the primary key in the database
command to migrate database using Rake
$ bundle exec rake db:migrate. simply update the database with our new user data model. bundle exec to make sure rake corresponds to our gemfile version.
rails s
shorcut for rails server
make utility
in unix, building executable programs from source codes. commonly used to compile code
rake
rails uses rake extensively especially in developing database-backed web applications. rake db:migrate most common.
(root URL)/users
page to list all users (index)
/users/1
page to show user with id 1 (show)
/users/new
page to make a new user (new)
/users/1/edit
page to edit user with id 1 (edit)