Skip to content

Commit 55d0275

Browse files
committed
Merge branch 'edge' of github.com:hyperstack-org/hyperstack into edge
2 parents 9a69a6d + c0ec909 commit 55d0275

File tree

1 file changed

+21
-70
lines changed

1 file changed

+21
-70
lines changed

docs/tutorial/todo.md

Lines changed: 21 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
# TodoMVC Tutorial (Rails 5.2.0)
2+
# TodoMVC Tutorial (Rails 5.2.x)
33

44
### Prerequisites
55

66
{ [Ruby On Rails](http://rubyonrails.org/) }
77

88
### The Goals of this Tutorial
99

10-
In this tutorial you will build the classic [TodoMVC](http://todomvc.com) application using Hyperloop
10+
In this tutorial, you will build the classic [TodoMVC](http://todomvc.com) application using Hyperloop. This tutorial will demonstrate all Hyperloop concepts - client side Components and Isomorphic Models.
1111

1212
The finished application will
1313

@@ -20,74 +20,23 @@ The finished application will
2020

2121
You will write less than 100 lines of code, and the tutorial should take about 1-2 hours to complete.
2222

23-
You can find the older application source code here:
24-
25-
2623
### Skills required
2724

28-
Working knowledge of Rails and Hyperloop required
25+
Working knowledge of Rails required
2926

3027
### Chapter 1: Setting Things Up
3128

32-
Create a new rails application
33-
```ruby
34-
rails _5.2.0_ new hyperloop_todo
35-
```
36-
_5.2.0_ will insure you are creating a rails 5.2 appear (tested with 5.0 and 5.1)
37-
38-
Add Hyperloop to your Gemfile
39-
40-
Until our official release, add the following to your Gemfile:
41-
```ruby
42-
...
43-
# lap0 will use the latest release candidate
44-
gem 'hyperloop', '~> 1.0.0.lap0', git: 'https://github.com/ruby-hyperloop/hyperloop.git', branch: 'edge'
45-
gem 'hyperloop-config', '~> 1.0.0.lap0', git: 'https://github.com/ruby-hyperloop/hyperloop-config.git', branch: 'edge'
46-
...
47-
```
48-
49-
then
50-
```ruby
51-
bundle install
52-
```
53-
54-
Once the Hyperloop Gem and all its dependencies have been installed, it's time to run the hyperloop install generator.
55-
```ruby
56-
rails g hyperloop:install
57-
```
58-
59-
The generator creates the hyperloop structure inside the /app directory :
60-
```ruby
61-
/app/hyperloop/
62-
/app/hyperloop/components
63-
/app/hyperloop/models
64-
/app/hyperloop/operations
65-
/app/hyperloop/stores
66-
```
67-
68-
And updates your app/assets/javascripts/application.js file adding these lines:
69-
```ruby
70-
//= require hyperloop-loader
71-
Opal.OpalHotReloader.$listen() // optional (port, false, poll_seconds) i.e. (8081, false, 1)
72-
```
29+
+ `rails new MyApp`
30+
+ `cd MyApp` directory
31+
+ add `gem 'hyperloop'` to the Gemfile
32+
+ `bundle install`
33+
+ `run rails g hyperloop:install`
7334

74-
To be sure everything is setting up correctly, check your app/assets/javascripts/application.js:
75-
```ruby
76-
...
77-
//= require rails-ujs
78-
//= require activestorage
79-
//= require turbolinks
80-
//= require_tree .
81-
//= require hyperloop-loader
82-
Opal.OpalHotReloader.$listen() // optional (port, false, poll_seconds) i.e. (8081, false, 1)
83-
```
35+
#### Start the Rails app
8436

85-
Run foreman
86-
```ruby
87-
$ foreman start
88-
```
37+
+ `bundle exec foreman start` to start Rails and OpalHotReloader
8938

90-
Navigate to the given location and you should see the word **App** displayed on the page.
39+
Navigate to `http://localhost:5000/` and you should see the word **App** displayed on the page.
9140

9241
### Chapter 2: Hyperloop Models are Rails Models
9342

@@ -97,11 +46,11 @@ We are going to add our Todo Model, and discover that Hyperloop models are in fa
9746
+ Changes to models on the server are synchronized with all participating browsers.
9847
+ Data access is is protected by a robust *policy* mechanism.
9948

100-
>*A Rails ActiveRecord Model is a Ruby class that is backed by a database table. In this example we will have one model class called `Todo`. When manipulating models, Rails automatically generates the necessary SQL code for you. So when `Todo.all` is evaluated Rails generates the appropriate SQL
101-
and turns the result of the query into appropriate Ruby data structures.*
49+
>A Rails ActiveRecord Model is a Ruby class that is backed by a database table. In this example we will have one model class called `Todo`. When manipulating models, Rails automatically generates the necessary SQL code for you. So when `Todo.all` is evaluated Rails generates the appropriate SQL
50+
and turns the result of the query into appropriate Ruby data structures.
10251

103-
>*Hyperloop Models are extensions of ActiveRecord Models that synchronize the data between the client and server
104-
automatically for you. So now `Todo.all` can be evaluated on the server or the client.*
52+
**Hyperloop Models are extensions of ActiveRecord Models that synchronize the data between the client and server
53+
automatically for you. So now `Todo.all` can be evaluated on the server or the client.**
10554

10655
Okay lets see it in action:
10756

@@ -130,11 +79,13 @@ Okay lets see it in action:
13079
which will create the table.
13180

13281
2. **Make Some Models Public:**
133-
*Move* `models/todo.rb` and `models/application_record.rb` to `hyperloop/models`.
13482

135-
This will make the model accessible on the clients *and the server*, subject to any data access policies.
83+
+ *Move* `models/todo.rb` to `hyperloop/models`
84+
+ Stop and restart your rails server
85+
86+
This will make the model accessible on the clients *and the server*, subject to any data access policies.
13687

137-
*Note: The hyperloop installer adds a policy that gives full permission to all clients but only in development and test modes. Have a look at `app/policies/application_policy` if you are interested.*
88+
*Note: The hyperloop installer adds a policy that gives full permission to all clients but only in development and test modes. Have a look at `app/policies/application_policy` if you are interested.*
13889

13990
3. **Try It**
14091
Change your `App` component's render method to:
@@ -966,4 +917,4 @@ end
966917

967918
3: Its possible to get things so messed up the hot-reloader will not work. Restart the server and reload the browser.
968919

969-
You can find the final application source code here:
920+
4: Reach out to us on Gitter, we are always happy to help get you onboarded!

0 commit comments

Comments
 (0)