-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to the Getting Started guide #406
Improvements to the Getting Started guide #406
Conversation
@@ -319,7 +319,7 @@ To make our test pass, we need to edit our newly generated template file in `app | |||
</div> | |||
``` | |||
|
|||
Save your changes and see your tests pass! | |||
Save your changes and see your tests pass! The output will also contain a skipped test. This is due to an autogenerated test in `spec/web/views/books/index_spec.rb`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be said explicitly, because it might confuse people.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
@@ -386,7 +386,7 @@ The generator gives us an entity, a repository, a migration, and accompanying te | |||
|
|||
### Migrations To Change Our Database Schema | |||
|
|||
Let's modify the generated migration to include `title` and `author` fields: | |||
Let's modify the generated migration (the path to the migration will differ for you, because it contains a timestamp) to include `title` and `author` fields: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the path to migration and messed up my development database, because it tried to create the books twice π
@@ -422,7 +422,7 @@ Let's prepare our database for the development and test environments: | |||
An entity is something really close to a plain Ruby object. | |||
We should focus on the behaviors that we want from it and only then, how to save it. | |||
|
|||
For now, we need to create simple entity class: | |||
For now, we keep the generated entity class: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed about this file, so we should state that.
@@ -435,7 +435,7 @@ We can verify it all works as expected with a unit test: | |||
|
|||
```ruby | |||
# spec/bookshelf/entities/book_spec.rb | |||
require 'spec_helper' | |||
require_relative '../../spec_helper' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the generators generate the tests with a require_relative
. I think either the generator or the guide should be adjusted.
@@ -506,8 +506,7 @@ Let's write a test to force this change in our view: | |||
|
|||
```ruby | |||
# spec/web/views/books/index_spec.rb | |||
require 'spec_helper' | |||
require_relative '../../../../apps/web/views/books/index' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generator also doesn't require the files. Again: I think either the generator or the guide should be adjusted.
source/guides/1.1/getting-started.md
Outdated
|
||
6 runs, 7 assertions, 0 failures, 0 errors, 0 skips | ||
9 runs, 16 assertions, 0 failures, 0 errors, 0 skips |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We autogenerated some tests, so these coutns were wrong.
@@ -768,7 +765,7 @@ describe Web::Controllers::Books::Create do | |||
end | |||
``` | |||
|
|||
Making these tests pass is easy enough. | |||
Let's make these tests pass! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience it is not a good idea to tell someone that something is "easy enough". What if the reader did not understand it? They might feel pretty stupid when they are told that this is supposed to be easy.
|
||
# Running: | ||
|
||
............... | ||
...S.S......... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, some auto generated tests are skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the seed? Changing it doesn't make much sense to me.
@@ -980,7 +976,7 @@ end | |||
``` | |||
|
|||
In our template we can loop over `params.errors` (if there are any) and display a friendly message. | |||
Open up `apps/web/templates/books/new.html.erb`: | |||
Open up `apps/web/templates/books/new.html.erb` and add the following at the top of the file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up until now we always presented the entire file. Here we only show a piece of it. Maybe we should just paste the entire file here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
@@ -1031,7 +1029,7 @@ resources :books, only: [:index, :new, :create] | |||
``` | |||
|
|||
To get a sense of what routes are defined, now we've made this change, you can | |||
use the special command-line task `routes` to inspect the end result: | |||
run `bundle exec hanami routes` on your command-line to inspect the end result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to tell the reader what they should run in their command-line.
@@ -1056,7 +1054,7 @@ Remember how we built our form using `form_for`? | |||
%> | |||
``` | |||
|
|||
It's silly to include a hard-coded path in our template, when our router is already perfectly aware of which route to point the form to. | |||
We don't need to include a hard-coded path in our template, when our router is already perfectly aware of which route to point the form to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calling something the reader did "silly" is not a good idea.
Hey π Just wanted to know what the status is here πΊ |
Hi @moonglum, thanks very much for your contribution. I've been on holidays for a week, but I will look at it until Sunday :-) |
@marionschleifer That's amazing! Thank you π |
@@ -177,7 +177,7 @@ As you can see, we have set `HANAMI_ENV` environment variable to instruct our co | |||
Now we have a test, we can see it fail: | |||
|
|||
``` | |||
% rake test | |||
% bundle exec rake test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
@@ -319,7 +319,7 @@ To make our test pass, we need to edit our newly generated template file in `app | |||
</div> | |||
``` | |||
|
|||
Save your changes and see your tests pass! | |||
Save your changes and see your tests pass! The output will also contain a skipped test. This is due to an autogenerated test in `spec/web/views/books/index_spec.rb`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
source/guides/1.0/getting-started.md
Outdated
@@ -347,7 +347,7 @@ Open up the file `apps/web/templates/application.html.erb` and edit it to look l | |||
</html> | |||
``` | |||
|
|||
Now you can remove the duplicate lines from the other templates. | |||
Now you can remove the duplicate lines from the other templates. Let's run the tests again to check that everything worked fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a command running the tests should be inserted here?
@@ -386,7 +386,7 @@ The generator gives us an entity, a repository, a migration, and accompanying te | |||
|
|||
### Migrations To Change Our Database Schema | |||
|
|||
Let's modify the generated migration to include `title` and `author` fields: | |||
Let's modify the generated migration (the path to the migration will differ for you, because it contains a timestamp) to include `title` and `author` fields: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
@@ -422,7 +422,7 @@ Let's prepare our database for the development and test environments: | |||
An entity is something really close to a plain Ruby object. | |||
We should focus on the behaviors that we want from it and only then, how to save it. | |||
|
|||
For now, we need to create simple entity class: | |||
For now, we keep the generated entity class: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π The class is already created by the generator.
@@ -1031,7 +1029,7 @@ resources :books, only: [:index, :new, :create] | |||
``` | |||
|
|||
To get a sense of what routes are defined, now we've made this change, you can | |||
use the special command-line task `routes` to inspect the end result: | |||
run `bundle exec hanami routes` on your command-line to inspect the end result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the actual command is below. IMHO it's better to keep the original wording, since it makes the user acquainted with what a "task" means.
@@ -1056,7 +1054,7 @@ Remember how we built our form using `form_for`? | |||
%> | |||
``` | |||
|
|||
It's silly to include a hard-coded path in our template, when our router is already perfectly aware of which route to point the form to. | |||
We don't need to include a hard-coded path in our template, when our router is already perfectly aware of which route to point the form to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
@@ -319,7 +319,7 @@ To make our test pass, we need to edit our newly generated template file in `app | |||
</div> | |||
``` | |||
|
|||
Save your changes and see your tests pass! | |||
Save your changes and see your tests pass! The output will also contain a skipped test. This is due to an autogenerated test in `spec/web/views/books/index_spec.rb`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
|
||
# Running: | ||
|
||
............... | ||
...S.S......... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the seed? Changing it doesn't make much sense to me.
@@ -980,7 +976,7 @@ end | |||
``` | |||
|
|||
In our template we can loop over `params.errors` (if there are any) and display a friendly message. | |||
Open up `apps/web/templates/books/new.html.erb`: | |||
Open up `apps/web/templates/books/new.html.erb` and add the following at the top of the file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks a lot @moonglum π
Dear @moonglum thank you very much for your great contribution π· If you would like me to send you some Hanami stickers, please send me your postal address via email (marion.schleifer@gmail.com) π |
@marionschleifer Thank you so much π More contributions will be coming soon πΈ |
I've just made my way through the Getting Started guide. It's really well written, thank you for that π I noticed some things along the way that could be improved in my opinion β I've added some comments to the changes I made in the 1.1 guide (the changes in the 1.0 are the same ones).