Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ecruby/ecruby
base: a48b87bc65
...
head fork: ecruby/ecruby
compare: 63b9068e4d
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
9 src/pages/camp/install.haml
@@ -83,7 +83,8 @@
Once done, continue with the rest of the steps.
Generate you ssh Key Pair
- ssh-keygen -t rsa -C "your_email@youremail.com"
+
+ ssh-keygen -t rsa -C "your_email@youremail.com"
Configuring your environment
=========
@@ -97,7 +98,7 @@
In the shell, type
- gem install sinatra sinatra-reloader pony heroku
+ gem install sinatra sinatra-reloader pony heroku taps
Next, type
@@ -107,13 +108,13 @@
Finally, see if Rails works. At the shell, type
- rails new test
+ rails new test_app
This creates a new Rails application in a folder called `test`
Type
- cd test
+ cd test_app
rails g scaffold item name:string
rake db:migrate
rails server
View
97 src/pages/camp/rails.haml
@@ -10,11 +10,13 @@
rails new shoppinglist
cd shoppinglist
- Creating our first controller is as easy as using the generator. Specify the generator `controller` and then the name of the controller, followed by the names of the pages you want, separated by spaces.
+ Creating our first controller is as easy as using the `rails generate` command. Specify the generator `controller` and then the name of the controller, followed by the names of the pages you want, separated by spaces. We'll use the shorthand version of `rails generate`, which is `rails g`. Type this into your shell:
rails g controller pages index about
- This generates the controller and two view pages.
+ This generates the controller and two view pages.
+
+
Now open `app/views/pages/index.html.erb` and change the content to this:
@@ -121,6 +123,8 @@
<li><%= link_to "About", about_path %></li>
</ul>
+ But in order to use our home page properly, we have to delete the file `public/index.html`
+
## Workshop 2: Lists with Scaffolding
Create the list interface with
@@ -386,7 +390,7 @@
</ul>
</div>
- Now create a similar file to list the items of the list in `app/views/items.mobile.erb` with this content:
+ Now create a similar file to list the items of the list in `app/views/index.mobile.erb` with this content:
<div data-role="header">
<h1><%= @list.name %></h1>
@@ -396,7 +400,7 @@
<ul id="mobile_items" data-role="listview">
<% @items.each do |item| %>
<li>
- <%=form_for [@list, item], :format => "json", :remote => true do |f| %>
+ <%=form_for [@list, item], :format => "json" do |f| %>
<%=f.check_box :done %>
<%=f.label :done, item.name %>
<% end %>
@@ -407,12 +411,81 @@
To make the links work properly, we have to add more JS. We can't rely on Rails' forms to do this for us. Add this to `app/assets/items.coffee` and be sure it's indented evenly with the previous code, so that it's nested within the scope of the `$ ->`
- $('#mobile_items input').on 'click', ->
- form = $(this).closest('form')
- $.ajax
- url: form.attr("action")
- dataType: "json"
- type: "PUT"
- data: form.serialize()
+ $('#mobile_items input').on 'click', ->
+ form = $(this).closest('form')
+ $.ajax
+ url: form.attr("action")
+ dataType: "json"
+ type: "PUT"
+ data: form.serialize()
+
+ Now visit http://localhost:3000/lists.mobile and you should be able to use the app!
+
+ ## Workshop 6: Sharing With The World
+
+ Heroku hosts our apps for free. But we have to use a different database.
+
+ Open `Gemfile` and change this:
+
+ gem 'sqlite3'
+
+ to
+
+ group :development, :test do
+ gem 'sqlite3'
+ end
+ group :production do
+ gem 'pg'
+ end
+
+ Heroku uses the `thin` web server. We'll need
+ to add this to our `Gemfile` as well:
+
+ group :production do
+ gem 'thin'
+ end
+
+ Then run
+
+ bundle install --without production
+
+
+ Then add everything to a new Git repository for deployment:
+
+ git init
+ git add .
+ git commit -m "First deployment"
+
+ Then we create our app on Heroku - use your initials.
+
+ heroku create bphshoppinglist --stack cedar
+
+ We can get info about our setup with this command:
+
+ heroku info --app myapp
+
+ Then commit the app
+
+ git push heroku master
+
+ This pushes the app into production! But it doesn't have a database.
+
+ heroku run rake db:setup
+
+ Now you can visit your site at yoursitename.herokuapps.com.
+
+ But there's no data, so let's push our local database up to the server!
+
+ heroku db:push
+
+ Now the data is up on the server.
+
+ That's it! Your first app is deployed. To make changes to your app, edit your files and redeploy the app. To redeploy, you have to commit your changes to your local Git repository and push again.
+
- Now visit http://localhost:3000/lists.mobile and you should be able to use the app!
+ git add .
+ git commit -m "I made changes"
+ git push heroku master
+
+ Of course, there's more to working with Rails than this, but this just gets you started.
+
View
4 src/stylesheets/style.sass
@@ -26,6 +26,10 @@ pre
margin-bottom: $measure
overflow: auto
+code
+ font-family: "Courier New", "Courier", monospace
+ font-weight: bold
+ background-color: $code_background
@media only screen and (min-width: 768px)

No commit comments for this range

Something went wrong with that request. Please try again.