Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more content tweaks

  • Loading branch information...
commit b161ea5e01856cf4cfc92c1258469e804a38733d 1 parent 07cf09d
Ryan Davis zenspider authored
4 lessons/01.yaml
View
@@ -53,13 +53,13 @@ content: |
You can verify that you have everything working by trying this out in your terminal:
- % irb
+ $ irb
>> 1 + 2
=> 3
>> require "active_support"
=> true
>> exit
- %
+ $
If you can do that, you are probably good to go.
52 lessons/02.yaml
View
@@ -13,34 +13,32 @@ goal: |
steps: |
- * open up a terminal window and try the following:
+ Open up a terminal window and try the following:
- <pre>
- irb
-
- 3 + 3
- 7 * 6
-
- my_variable = 5
-
- my_variable + 2
- my_variable * 3
-
- puts my_variable
-
- fruits = ["kiwi", "strawberry", "plum"]
-
- fruits + ["orange"]
- fruits - ["kiwi"]
-
- fruits.each do |f|
- puts f
- end
-
- if my_variable > 1 then
- puts "YAY!"
- end
- </pre>
+ $ irb
+
+ 3 + 3
+ 7 * 6
+
+ my_variable = 5
+
+ my_variable + 2
+ my_variable * 3
+
+ puts my_variable
+
+ fruits = ["kiwi", "strawberry", "plum"]
+
+ fruits + ["orange"]
+ fruits - ["kiwi"]
+
+ fruits.each do |f|
+ puts f
+ end
+
+ if my_variable > 1 then
+ puts "YAY!"
+ end
explanation: |
19 lessons/03.yaml
View
@@ -6,7 +6,7 @@ content: |
ri is a tool to look up ruby documentation:
- % ri String.split
+ $ ri String.split
= String.split
(from ruby core)
@@ -28,7 +28,7 @@ content: |
If running ri doesn't work and you've installed ruby using rvm, try
running this command first:
- rvm docs generate
+ $ rvm docs generate
### irb
@@ -38,15 +38,18 @@ content: |
Add this to a file called ~/.irbrc:
- class Object
- def pim inherited = false
- self.class.public_instance_methods(inherited).sort -
- Object.public_instance_methods
- end
- end
+ <pre class="code">
+ class Object
+ def pim inherited = false
+ self.class.public_instance_methods(inherited).sort -
+ Object.public_instance_methods
+ end
+ end
+ </pre>
Now you can do stuff like:
+ $ irb
>> "blah".pim
=> ["%", "*", "+", "<<", "<=>", "[]", "[]=", "bytes", "bytesize", ...]
10 lessons/04.yaml
View
@@ -15,11 +15,11 @@ steps: |
Open up a terminal window and try out the following.
- mkdir railsbridge
- cd railsbridge
- rails new suggestotron
- cd suggestotron
- ls
+ $ mkdir railsbridge
+ $ cd railsbridge
+ $ rails new suggestotron
+ $ cd suggestotron
+ $ ls
If you have _any_ problems, contact a TA immediately.
6 lessons/05.yaml
View
@@ -1,11 +1,9 @@
---
steps: |
- * In your terminal, try:
+ In your terminal, try:
- <pre>
- git init .
- </pre>
+ $ git init .
goal: |
26 lessons/06.yaml
View
@@ -1,14 +1,12 @@
---
steps: |
- * In your terminal, try:
+ In your terminal, try:
- <pre>
- git status
- git add .
- git commit -m "Added all the things"
- git status
- </pre>
+ $ git status
+ $ git add .
+ $ git commit -m "Added all the things"
+ $ git status
goal: |
@@ -19,10 +17,10 @@ goal: |
goal_title: Add the project to the git repo
explanation: |
- * "git status" tells you everything git sees as modified, new, or missing.
- ** The first time you run this, you should see a ton of stuff.
- ** The second time you run this, you shouldn't see much of anything.
- * "git add" tells git that you want to add the current directory and everything under it to the repo.
- * "git commit" tells git to actually _do_ all things you've said you wanted to do.
- ** This is done in two steps so you can group multiple changes together.
- ** '-m "Added all the things"' is just a shortcut to say what your commit message is. You can skip that part and git will bring up an editor to fill out a more detailed message.
+ * `git status` tells you everything git sees as modified, new, or missing.
+ * The first time you run this, you should see a ton of stuff.
+ * The second time you run this, you shouldn't see much of anything.
+ * `git add .` tells git that you want to add the current directory (aka `.`) and everything under it to the repo.
+ * `git commit` tells git to actually _do_ all things you've said you wanted to do.
+ * This is done in two steps so you can group multiple changes together.
+ * `-m "Added all the things"` is just a shortcut to say what your commit message is. You can skip that part and git will bring up an editor to fill out a more detailed message.
6 lessons/07.yaml
View
@@ -8,9 +8,9 @@ steps: |
In your terminal, try:
- heroku create
- git push heroku master
- heroku open
+ $ heroku create
+ $ git push heroku master
+ $ heroku open
explanation: |
4 lessons/08.yaml
View
@@ -8,8 +8,8 @@ steps: |
In your terminal, try this:
- bundle
- rails server
+ $ bundle
+ $ rails server
Then point your web browser to [http://localhost:3000](http://localhost:3000).
8 lessons/09.yaml
View
@@ -24,9 +24,9 @@ steps: |
Try the following in your terminal:
- rails generate scaffold topic title:string description:text
- rake db:migrate
- rails server
+ $ rails generate scaffold topic title:string description:text
+ $ rake db:migrate
+ $ rails server
If you want, take some time to poke around the files listed in the generate step.
@@ -67,4 +67,4 @@ explanation: |
In MVC, models, views, and controllers have very specific jobs. Separating
responsibilities like this make it easy to maintain and extend rails
applications. When responsibilities become muddied it gets much harder to
- debug issues and add new functionality.
+ debug issues and add new functionality.
8 lessons/11.yaml
View
@@ -10,10 +10,10 @@ steps: |
In your terminal, try: (**note:** there is a period after the word
add in the first line)
- git add .
- git commit -m "Added topics"
- git push heroku master
- heroku rake db:migrate
+ $ git add .
+ $ git commit -m "Added topics"
+ $ git push heroku master
+ $ heroku rake db:migrate
explanation: |
13 lessons/12.yaml
View
@@ -1,23 +1,24 @@
---
section_title: Voting on Topics
section_content: |
-
+
goal_title: Creating a model for votes
goal: |
- Create another database table to track votes.
+ ![topics_table](/img/votes_table.png)
+
+ Every topic in suggestotron can be voted on. In order to count
+ votes, we need to record votes. We'll add that table now.
steps: |
In a terminal window type the following
- rails generate resource vote topic_id:integer
- rake db:migrate
+ $ rails generate resource vote topic_id:integer
+ $ rake db:migrate
explanation: |
- ![topics_table](/img/votes_table.png)
-
* Just like before, we're creating a new model named "vote"
* The only thing really different is the integer we added called topic_id.
* topic_id is the data we need to draw the line between votes and topics.
6 lessons/13.yaml
View
@@ -2,7 +2,11 @@
goal_title: Hooking up votes and topics
goal: |
- In this step, we'll create a relationship between votes and topics.
+ ![topics_and_votes_table](/img/topics_and_votes_table.png)
+
+ Because there is an explicit relationship between a topic and its
+ votes, we need to specify that. In this step, we'll explicitly
+ declare the relationship between votes and topics.
steps: |
8 lessons/15.yaml
View
@@ -3,10 +3,10 @@ steps: |
In your handy-dandy terminal, try:
- git add .
- git commit -m "Added votes"
- git push heroku master
- heroku rake db:migrate
+ $ git add .
+ $ git commit -m "Added votes"
+ $ git push heroku master
+ $ heroku rake db:migrate
goal: |
22 lessons/16.yaml
View
@@ -34,7 +34,7 @@ steps: |
You also need to remove the welcome aboard page for the new route to
work. Type this in a terminal window:
- git rm public/index.html
+ $ git rm public/index.html
Go back to [http://localhost:3000/](http://localhost:3000/). You
should be taken to the topics list automatically.
@@ -53,8 +53,10 @@ explanation: |
possible URLs. To explore the URLs in more detail we can use the
terminal.
- At the terminal type <pre> rake routes</pre> you should get
- something that looks like this:
+ At the terminal type `rake routes` you should get something that
+ looks like this:
+
+ $ rake routes
votes GET /votes(.:format) {:action=>"index", :controller=>"votes"}
POST /votes(.:format) {:action=>"create", :controller=>"votes"}
@@ -76,14 +78,18 @@ explanation: |
##### Exploring Routes (optional)
- Open up your rails console:
-
- rails console
Now you can have a look at the paths that are available in your app.
Let's try looking at one of the topics routes we just generated.
+ Open up your rails console and play:
- app.topics_path
+ $ rails console
+ >> app.topics_path
=> "/topics"
- app.topics_url
+ >> app.topics_url
=> "http://www.example.com/topics"
+
+ `app` is a special object that represents your entire application.
+ You can ask it about its routes (as we just did), play with its
+ database connections, or make pseudo-web requests against it with
+ `get` or `post` (and lots more).
52 lessons/17.yaml
View
@@ -11,23 +11,23 @@ goal: |
steps: |
- * Open `app/controllers/topics_controller.rb`
- * Look at the create method (it looks like this):
+ Open `app/controllers/topics_controller.rb` and look at the create
+ method (it looks like this):
<pre class="code">
- def create
- @topic = Topic.new(params[:topic])
-
- respond_to do |format|
- if @topic.save
- format.html { redirect_to @topic, :notice => 'Topic was successfully created.' }
- format.json { render :json => @topic, :status => :created, :location => @topic }
- else
- format.html { render :action => "new" }
- format.json { render :json => @topic.errors, :status => :unprocessable_entity }
- end
+ def create
+ @topic = Topic.new(params[:topic])
+
+ respond_to do |format|
+ if @topic.save
+ format.html { redirect_to @topic, :notice => 'Topic was successfully created.' }
+ format.json { render :json => @topic, :status => :created, :location => @topic }
+ else
+ format.html { render :action => "new" }
+ format.json { render :json => @topic.errors, :status => :unprocessable_entity }
end
end
+ end
</pre>
Change the line:
@@ -38,23 +38,23 @@ steps: |
so that the file looks like this:
- <pre>
- def create
- @topic = Topic.new(params[:topic])
-
- respond_to do |format|
- if @topic.save
- format.html { redirect_to topics_path, :notice => 'Topic was successfully created.' }
- format.json { render :json => @topic, :status => :created, :location => @topic }
- else
- format.html { render :action => "new" }
- format.json { render :json => @topic.errors, :status => :unprocessable_entity }
- end
+ <pre class="code">
+ def create
+ @topic = Topic.new(params[:topic])
+
+ respond_to do |format|
+ if @topic.save
+ format.html { redirect_to topics_path, :notice => 'Topic was successfully created.' }
+ format.json { render :json => @topic, :status => :created, :location => @topic }
+ else
+ format.html { render :action => "new" }
+ format.json { render :json => @topic.errors, :status => :unprocessable_entity }
end
end
+ end
</pre>
- * Try it out [http://localhost:3000 http://localhost:3000]
+ Look at it at [http://localhost:3000](http://localhost:3000).
explanation: |
31 lessons/18.yaml
View
@@ -9,29 +9,30 @@ goal: |
steps: |
- * Let's start by removing the description
- * Open `app/views/topics/index.html.erb`
- * Delete the line that looks like this:
+ Let's start by removing the description. Open
+ `app/views/topics/index.html.erb` and delete the line that looks
+ like this:
<pre class="code">
&lt;td>&lt;%= topic.description %>&lt;/td>
</pre>
- * Also delete the line that looks like this:
+ Also delete the line that looks like this:
<pre class="code">
&lt;th>Description&lt;/th>
</pre>
- * If you save and try to load it in the browser you should see that the description no longer appears
- * Now to make the title a link
- * In `app/views/topics/index.html.erb` again replace this line:
+ If you save and try to load it in the browser you should see that
+ the description no longer appears. Now make the title a link by
+ editing `app/views/topics/index.html.erb` (again) and replace this
+ line:
<pre class="code">
&lt;td>&lt;%= topic.title %>&lt;/td>
</pre>
- with this
+ with this:
<pre class="code">
&lt;td>&lt;%= link_to topic.title, topic %>&lt;/td>
@@ -42,15 +43,23 @@ explanation: |
<pre class="code">
&lt;td><%= topic.description %>&lt;/td>
</pre>
- * This line was getting the description using .description and just printing it out
+
+ This line was getting the description using .description and just printing it out
<pre class="code">
&lt;th>Description&lt;/th>
</pre>
- * <th> stands for table header and everything between <th> and </th> was being printed as a table header (bold). We removed it since we removed the description and it would look funny to have the header and the wrong thing below it.
+
+ `<th>` stands for table header and everything between `<th>` and
+ `</th>` was being printed as a table header (bold). We removed it
+ since we removed the description and it would look funny to have the
+ header and the wrong thing below it.
<pre class="code">
&lt;td><%= link_to topic.title, topic %>&lt;/td>
</pre>
- * Here's another use of link_to to create a link on the page. This link_to creates a link using the text from the topic title and goes to the topic#show page.
+
+ Here's another use of `link_to` to create a link on the page. This
+ `link_to` creates a link using the text from the topic title and goes
+ to the topic#show page.
9 lessons/19.yaml
View
@@ -13,27 +13,24 @@ goal: |
steps: |
- * Open `app/views/topics/index.html.erb`
- * Remove these two lines:
+ Open `app/views/topics/index.html.erb` and remove these two lines:
<pre class="code">
&lt;td>&lt;%= link_to 'Show', topic %>&lt;/td>
&lt;td>&lt;%= link_to 'Edit', edit_topic_path(topic) %>&lt;/td>
</pre>
- * Change the line with the word 'Destroy' to this
+ Change the line with the word 'Destroy' to this:
<pre class="code">
&lt;td>&lt;%= link_to 'Delete', topic, :confirm => 'Are you sure?', :method => :delete %>&lt;/td>
</pre>
- * Save your file and try reloading in your browser to see the changes.
+ Now save your file and try reloading in your browser to see the changes.
explanation: |
-
* The two links we removed were show and edit. We did this because the title now links to the show page and from the show page you can reach the edit page.
-
* The second change we made was to make the link text 'Delete' instead of destroy.
4 lessons/20.yaml
View
@@ -8,8 +8,8 @@ steps: |
Again with the terminal:
- git commit -m "Added topics" .
- git push heroku master
+ $ git commit -m "Added topics" .
+ $ git push heroku master
explanation: |
Please sign in to comment.
Something went wrong with that request. Please try again.