Skip to content

Add comment opinion#2

Open
magdabm wants to merge 2 commits intomasterfrom
add_comment_opinion
Open

Add comment opinion#2
magdabm wants to merge 2 commits intomasterfrom
add_comment_opinion

Conversation

@magdabm
Copy link
Owner

@magdabm magdabm commented Feb 3, 2019

No description provided.

tojawawel
tojawawel approved these changes Feb 3, 2019
o.opinion
end
array.sum
end

Choose a reason for hiding this comment

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

To można zrobić wbudowaną metodą.

Copy link
Owner Author

Choose a reason for hiding this comment

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

A tak, mam ją, zapomniałam tej skasować :)


private
def opinion_params
params.require(:opinion).permit(:opinion, :user)

Choose a reason for hiding this comment

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

Czy user jest tu potrzebny?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Nie mogłam zapisać opinii do bazy bez usera, dlatego że mam połączoną opinię z userem (w bazie foreign key, a w aplikacji belongs to).

belongs_to :user
belongs_to :comment

validates :user, uniqueness: { scope: :opinion }

Choose a reason for hiding this comment

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

To dotyczy komentarza a nie opini o komentarzu

Copy link
Owner Author

Choose a reason for hiding this comment

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

Racja, w drugim commicie już zmienione.

belongs_to :user
has_many :opinions
has_many :opinions, dependent: :destroy
has_many :users, through: :opinions

Choose a reason for hiding this comment

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

Czy tu nie wystarczy zwykle has_many?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Możliwe! Sugerowałam się relacjami z artykułów...

Copy link

@tojawawel tojawawel left a comment

Choose a reason for hiding this comment

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

Test komentarza.

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