Skip to content
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

Merged
merged 1 commit into from
Nov 6, 2017
Merged

Improvements to the Getting Started guide #406

merged 1 commit into from
Nov 6, 2017

Conversation

moonglum
Copy link
Contributor

@moonglum moonglum commented Oct 27, 2017

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).

@@ -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`.
Copy link
Contributor Author

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.

Copy link
Contributor

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:
Copy link
Contributor Author

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:
Copy link
Contributor Author

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'
Copy link
Contributor Author

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'
Copy link
Contributor Author

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.


6 runs, 7 assertions, 0 failures, 0 errors, 0 skips
9 runs, 16 assertions, 0 failures, 0 errors, 0 skips
Copy link
Contributor Author

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!
Copy link
Contributor Author

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.........
Copy link
Contributor Author

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.

Copy link
Contributor

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:
Copy link
Contributor Author

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?

Copy link
Contributor

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:
Copy link
Contributor Author

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.
Copy link
Contributor Author

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.

@moonglum
Copy link
Contributor Author

moonglum commented Nov 2, 2017

Hey πŸ‘‹ Just wanted to know what the status is here 😺

@marionschleifer
Copy link
Member

Hi @moonglum, thanks very much for your contribution. I've been on holidays for a week, but I will look at it until Sunday :-)

@moonglum
Copy link
Contributor Author

moonglum commented Nov 3, 2017

@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
Copy link
Contributor

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘

@@ -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.
Copy link
Contributor

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:
Copy link
Contributor

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:
Copy link
Contributor

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:
Copy link
Contributor

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.
Copy link
Contributor

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘


# Running:

...............
...S.S.........
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘

@moonglum
Copy link
Contributor Author

moonglum commented Nov 3, 2017

Adressed @apohllo's comments in f78bc22

Copy link
Member

@marionschleifer marionschleifer left a 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 πŸ‘

@marionschleifer
Copy link
Member

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 marionschleifer merged commit 7030571 into hanami:build Nov 6, 2017
@moonglum moonglum deleted the getting-started-improvements branch November 7, 2017 08:24
@moonglum
Copy link
Contributor Author

moonglum commented Nov 7, 2017

@marionschleifer Thank you so much πŸ‘ More contributions will be coming soon 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants