I am trying to understand this line of code:
@rating = Rating.where(review_id: @review.id, user_id: @current_user.id).first
The line of code comes from a Ruby on Rails app that has a user, review, and rating model. Here is what I understand so far:
- @rating is a variable
- Rating.where().first is a method
- review_id: @review.id + user_id: @current_user.id are parameters- and are an implicit hash key/value pair
How does review_id: @review.id or user_id: @current_user.id work with the database?
Update question: Sorry I'm still confused. How does @review.id or @current_user.id point to anything in the database? I have nothing in my database starting with the @ symbol