Skip to content

Week10#14

Merged
up2code3 merged 5 commits into
mainfrom
week10
Oct 1, 2025
Merged

Week10#14
up2code3 merged 5 commits into
mainfrom
week10

Conversation

@up2code3
Copy link
Copy Markdown
Owner

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

if @artist.save
redirect_to @artist, notice: "Artist Created"
else
render :new, status: :unprocessable_entity
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

make sure you are formatting

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ahh I understand.


private

def artist_params
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this right to use the name instead of ID

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah, thats my fault. miss understood what this was.

Comment thread app/models/track.rb
@@ -1,5 +1,5 @@
class Track < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why would this be optional?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

oh okay. Thats good to understand. Definitely should change it to current user.

@up2code3 up2code3 merged commit 70a406a into main Oct 1, 2025
3 checks passed
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.

2 participants