Skip to content

Commit 6fcd116

Browse files
committed
Merge pull request railsbridge#115 from lilliealbert/intermediate_rails
Add intermediate rails curriculum
2 parents 1edacb4 + 47edf15 commit 6fcd116

20 files changed

+354
-19
lines changed

lib/doc_page.rb

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def head_content
4949
end
5050

5151
def site_title
52-
"Railsbridge #{site_name.capitalize}"
52+
"Railsbridge #{site_name.split("_").map(&:capitalize).join(" ")}"
5353
end
5454

5555
def page_title

lib/step.rb

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ class Step < Erector::Widget
1616
padding-left: 1.5em;
1717
margin-left: .25em;
1818
}
19+
}
20+
21+
img.noborder {
22+
border: none;
23+
display: inline;
24+
}
1925
26+
.centered {
27+
text-align: center;
2028
}
2129
2230
.message img.icon {
@@ -87,6 +95,22 @@ class Step < Erector::Widget
8795
background-color: #B0DEE7;
8896
}
8997
98+
.requirements>h1 {
99+
background-color: #93B5DA;
100+
}
101+
102+
.discussion>h1 {
103+
background-color: #92F59A;
104+
}
105+
106+
.hints>h1 {
107+
background-color: #86DFD4;
108+
}
109+
110+
.tools_and_references>h1 {
111+
background-color: #C8A9E0;
112+
}
113+
90114
.console > pre {
91115
border: 4px solid #dde;
92116
@include border-radius(4px);
@@ -134,20 +158,22 @@ def page_name
134158

135159
## steps
136160

137-
def steps
138-
div :class => "steps" do
139-
h1 "Steps"
140-
blockquote do
141-
yield
142-
end
143-
end
144-
end
161+
@@header_sections = {
162+
steps:"Steps",
163+
explanation:"Explanation",
164+
discussion:"Discussion Items",
165+
hints:"Hints",
166+
tools_and_references:"Tools and References",
167+
requirements:"Requirements to advance",
168+
}
145169

146-
def explanation
147-
div :class => "explanation" do
148-
h1 "Explanation"
149-
blockquote do
150-
yield
170+
@@header_sections.each do |type, header|
171+
define_method type do |&block|
172+
div :class => type do
173+
h1 header
174+
blockquote do
175+
block.call if block
176+
end
151177
end
152178
end
153179
end
@@ -161,7 +187,7 @@ def consider_deploying
161187
end
162188
end
163189
end
164-
190+
165191
def step name = nil, options = {}
166192
num = next_step_number
167193
a(:name => "step#{current_anchor_num}")
@@ -264,7 +290,7 @@ def important text = nil, &block
264290
def tip text = nil, &block
265291
message text, class: "tip", icon: "info", &block
266292
end
267-
293+
268294
def todo todo_text
269295
message nil, class: "todo" do
270296
span do
@@ -276,10 +302,10 @@ def todo todo_text
276302
end
277303

278304
## special
279-
305+
280306
TERMINAL_CAPTION = "Type this in the terminal:"
281307
RESULT_CAPTION = "Expected result:"
282-
308+
283309
def console msg
284310
div :class => "console" do
285311
span TERMINAL_CAPTION
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
message <<-MARKDOWN
2+
What other features do you want?
3+
4+
Suggestions:
5+
6+
* Profile pages for users (enter user’s name or details, have it display alongside posts).
7+
* Post/Comment history for individual users (on their profile page?).
8+
* Easy user profile pictures with [Gravatar](https://gravatar.com/).
9+
* Add login options with [Omniauth](https://github.com/intridea/omniauth), including Twitter, Facebook, Github, Google, and more.
10+
* Check out the Devise [documentation for integrating with Omniauth](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview).
11+
* Fiddle with the layout of the show page so it doesn’t look bad. If it looks bad. It probably looks great.
12+
* Perhaps fancier post markup with Markdown or something similar.
13+
* Deploy to Heroku and send your message board to all your friends!
14+
15+
## ...and that's that! Good luck! Make more things! Come back again!
16+
MARKDOWN
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
requirements do
2+
message <<-MARKDOWN
3+
* The user should be able to create a post with a title, author, date published, and content. The author should be the current user.
4+
* The complete post should appear on its own page (aka its show page).
5+
* If the user doesn’t submit all required fields, they should see some error messaging, but shouldn’t lose any of their work.
6+
MARKDOWN
7+
table do
8+
tr do
9+
td do
10+
h2 'Create View', class: 'centered'
11+
end
12+
td do
13+
h2 'Show View', class: 'centered'
14+
end
15+
end
16+
tr do
17+
td do
18+
img class: 'noborder', src: 'img/create_post.png'
19+
end
20+
td do
21+
img class: 'noborder', src: 'img/show_post.png'
22+
end
23+
end
24+
end
25+
end
26+
27+
discussion do
28+
message <<-MARKDOWN
29+
* How do you create a resource? What parameters do you need to pass?
30+
* How will you associate the current user with the post?
31+
* Then: what did rails make for you when you used the resource generator? Find all the new files. Maybe even list them out on a whiteboard.
32+
* What's the difference between the `new` and `create` methods in the posts controller?
33+
MARKDOWN
34+
end
35+
36+
tools_and_references do
37+
message <<-MARKDOWN
38+
* RailsGuides - Form Helpers, section 2.2: <http://guides.rubyonrails.org/form_helpers.html#binding-a-form-to-an-object>
39+
* RailsGuides - Routes - CRUD, Verbs, and Actions: <http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions>.
40+
* RailsGuides - Active Record Validations and Callbacks: <http://guides.rubyonrails.org/active_record_validations_callbacks.html>
41+
MARKDOWN
42+
end
43+
44+
hints do
45+
message <<-MARKDOWN
46+
* Don't hand code the form! You don't have to! Rails will help. See RailsGuide link above!
47+
* Rails has a built-in way to note when something was stored in the database. Probably handy for showing the date / time a post was created.
48+
* For now, we're going to use the user's email address to identify them. You can add names or other identifiers later! (Also, even though you're going to get the current user's email address from the User model, you'll still need a user parameter for your Post resource.)
49+
* You need a `create` method to store your post data - scroll down a little bit in this section of the Getting Started guide for very helpful information and to see an example of a create method: <http://guides.rubyonrails.org/getting_started.html#creating-new-posts>.
50+
MARKDOWN
51+
end
52+
53+
next_step "make_a_posts_index_page"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
requirements do
2+
message <<-MARKDOWN
3+
* The user should see a 'New Reply' link or button on a post's show page which takes them to a form. The form should include the title of the post being replied to.
4+
* The user should be able to create a new reply to a post using the 'New Reply' form.
5+
* The user should see all the replies to a post on the post’s show page.
6+
* If the user doesn’t submit all required fields, they should see some error messaging, but they shouldn’t lose any of their work.
7+
MARKDOWN
8+
table do
9+
tr do
10+
td do
11+
h2 'Create View', class: 'centered'
12+
end
13+
td do
14+
h2 'Show View', class: 'centered'
15+
end
16+
end
17+
tr do
18+
td do
19+
img class: 'noborder', src: 'img/create_reply.png'
20+
end
21+
td do
22+
img class: 'noborder', src: 'img/show_replies.png'
23+
end
24+
end
25+
end
26+
end
27+
28+
discussion do
29+
message <<-MARKDOWN
30+
* What is a nested resource? When is it appropriate and how does it help?
31+
* How do the replies_controller and posts_controller interact?
32+
* What should happen to the routes file for this nesting business to work?
33+
MARKDOWN
34+
end
35+
36+
tools_and_references do
37+
message <<-MARKDOWN
38+
* RailsGuides - Rails Routing from the Outside In http://guides.rubyonrails.org/routing.html
39+
MARKDOWN
40+
end
41+
42+
next_step "inline_replying_on_a_post"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
requirements do
2+
message <<-MARKDOWN
3+
* You should have a new rails app with with a static home page that's under your control. Make sure the controller for this page is called **HomeController**.
4+
* You, the developer, should explain to a teacher, TA, or fellow student how Rails knows to render the home view.
5+
MARKDOWN
6+
img class: 'noborder', src: 'img/static_home_page.png'
7+
end
8+
9+
discussion do
10+
message <<-MARKDOWN
11+
* In order to have a static home page, you will need a route, a controller, a view. Discuss!
12+
* Seriously. If you don't discuss this stuff, things will be SO much harder.
13+
* We’re using `rails g resource` instead of `rails g scaffold` because it forces you, the developer, to do more understanding-building brain work. The teacher/TAs can perhaps comment on what they would do in the real world and their thoughts on the excellence of this choice for learning-purposes.
14+
* What do you need to add to your home controller (after you've made it) to have a static home page?
15+
* How does the home/index.html.erb view file relate to the layouts/application.html.erb view file?
16+
* What’s the significance of yield in the application view?
17+
* What does the home controller do?
18+
MARKDOWN
19+
end
20+
21+
tools_and_references do
22+
message <<-MARKDOWN
23+
* RailsGuides - Setting the Application Home Page: <http://guides.rubyonrails.org/getting_started.html#setting-the-application-home-page>.
24+
* Rails Guides - controllers overview: <http://guides.rubyonrails.org/action_controller_overview.html>.
25+
MARKDOWN
26+
end
27+
28+
hints do
29+
message <<-MARKDOWN
30+
* You'll definitely want to delete the index.html that Rails provides. If you can't find it, ask your neighbor!
31+
* If you have no idea what to put in your home controller, maybe try looking back at a past-Railsbridge app? Or another rails app you have lying about?
32+
MARKDOWN
33+
end
34+
35+
next_step "install_devise"
10.3 KB
Loading
9.94 KB
Loading
12.3 KB
Loading
31.1 KB
Loading

0 commit comments

Comments
 (0)