-
Notifications
You must be signed in to change notification settings - Fork 45
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
More Code Examples from the Programming Phoenix book #42
Conversation
…t all 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.
Just a couple of comments, but looks good.
Happy to merge after those are addressed.
I have been thinking about the syntax a little and would like your thoughts on this:
- We use Word Sigils throughout the book, but I feel that using just a normal List of strings instead would be more readable in general (perhaps I will find these to be nicer when I'm more used to the syntax).
- The
String.contains
syntax is initally more readable, but I have found the=~
syntax to be much nicer once you are used to it
Lastly, since we are running tests in the project, perhaps we could get these hosted?
rumbl/priv/repo/seeds.exs
Outdated
|
||
for category <- ~w(Action Drama Romance Comedy Sci-fi) do | ||
Repo.insert!(%Category{name: category}) || | ||
Repo.insert!(%Category{name: category}) |
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 these should be different, I have:
Repo.get_by(Category, name: category) ||
Repo.insert!(%Category{name: category})
instead
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.
@Shouston3 good shout. please feel free to edit the file in PR. 👍
else
I will fix tomorrow morning. 😉
create table(:categories) do | ||
add :name, :string, null: false | ||
|
||
timestamps() # function call parenthesis not in book! |
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.
Nice 👍
rumbl/test/controllers/auth_test.exs
Outdated
end | ||
|
||
test "login with password missmatch", %{conn: conn} do | ||
_ = insert_user(username: "me", password: "secrete") |
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.
"secrete" typo
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.
yeah, worth fixing. thanks. 👍
# test "changeset with invalid attributes" do | ||
# changeset = User.changeset(%User{}, @invalid_attrs) | ||
# refute changeset.valid? | ||
# end |
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 also have these comments in mine 👍
|
||
def create(conn, %{"video" => video_params}, user) do | ||
IO.inspect video_params | ||
IO.inspect user |
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.
Perhaps remove these IO.inspects
user | ||
|> build_assoc(:videos) | ||
|> Video.changeset(video_params) | ||
IO.inspect changeset |
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.
IO.inspect
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.
Will remove. in next commit. 👍
rumbl/web/models/video.ex
Outdated
|
||
timestamps() | ||
timestamps() # invocation parenthesis not in book |
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.
Ugh this has been confusing us with warnings
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.
@des-des are you running the latest version of Phoenix?
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.
@nelsonic yeah 1.2.1
rumbl/web/static/js/player.js
Outdated
@@ -0,0 +1,29 @@ | |||
let Player = { |
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.
JS -> Elm?!
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.
@des-des this example is from "The Book" ...
I don't intend to keep the ES6 after I've finished writing out the code. 😉
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.
hehe
…nd of rumbl/web/models/video.ex
…set.cast/4` is deprecated, please use `cast/3` + `validate_required/3` instead
…StackOverflow question ... see: #52
@iteles I've addressed the review comments from @Shouston3 & @des-des |
rumbl/web/static/js/player.js
Outdated
let Player = { | ||
player: null, | ||
|
||
let Player = { // JS works for small scripts like this |
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.
Also loving this pragmatism 👍
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.
This has been pretty fascinating to review. Nothing to add for now, thanks for putting it together!
@iteles adding code examples for the Programming Phoenix book
(I've personally written and tested the examples and been opening issues along the way e.g #38 so other people can learn faster...) 👍
Fixes #35, #49 & #50
Please review/merge when you can thanks.