Conversation
| if @artist.save | ||
| redirect_to @artist, notice: "Artist Created" | ||
| else | ||
| render :new, status: :unprocessable_entity |
There was a problem hiding this comment.
So I was a bit thrown off by this as well , in past if/else blocks (React JS) the else was always 1 indent to the right of the if, but in rails the Ruby style guide suggest the else is aligned with the if, and Rubocop enforces it that way.
|
|
||
| private | ||
|
|
||
| def artist_params |
There was a problem hiding this comment.
is this right to use the name instead of ID
There was a problem hiding this comment.
Yes, this is for creating an artist, It does not get an id until after it is created, What the user types in the params is to be the name of the artist.
There was a problem hiding this comment.
Yeah, thats my fault. miss understood what this was.
| @@ -1,5 +1,5 @@ | |||
| class Track < ApplicationRecord | |||
| belongs_to :user | |||
| belongs_to :user, optional: true | |||
There was a problem hiding this comment.
Ahh Yes that was my first attempt at creating a track without a user, Eventually I went with hardcoding user (username: Twhite) into the controller ( after the user/auth set up , i will change it to current_user )
TLDR - it was a work around for creating CRUD with out users, that i forgot to delete.
There was a problem hiding this comment.
oh okay. Thats good to understand. Definitely should change it to current user.
create new artist
create new track
edit track
delete track
links
note: user is hard coded in track controller
line 30 is Twhite once user auth is set up that will need to be current_user