With Ruby on Rails, you can buy and sell with individuals like time tickets I want to create a service like this.
In this process, we would like to make specifications so that "if a user has already reviewed the user, you can edit it instead of posting a review" in order to implement the review function.
I'm getting an error when using the if statement on the screen to determine if the user has reviewed.
Rails tutorial Partial of follow/follower cancellation form Is not displayed well.
undefined method `review_content? 'for #<User: 0x007fe1d210ac28> Did you mean? Review_content review_content = review_content_ids reviewed_content reviewed_content =
<% if current_user.review_content? (@ user)%> <div> <% = link_to @ user.username + "Edit reviews", edit_review_path%> </div> <% elsif @user! = current_user%> <div> <% = link_to @ user.username + "Write a review", new_review_path%> </div> <% end%>
class UsersController<ApplicationController def show @user = User.find (params [: id]) @reviews = @ user.passive_reviews end end
class User<ApplicationRecord ... has_many: review_content, through:: active_reviews, source:: reviewed has_many: reviewed_content, through:: passive_reviews, source:: reviewer end
class Review<ApplicationRecord belongs_to: reviewer, class_name: "User" belongs_to: reviewed, class_name: "User" validates: reviewer_id, presence: true validates: reviewed_id, presence: true end
Answer # 1
<% if current_user.review_content.include? (@ user)%>
It was possible.
- ruby - [rails] i want to save only check items in the db
- ruby - i can't save posts with form_with in rails 60
- ruby on rails - posts are not reflected on rails
- ruby on rails 5 - if there is already the same product in the cart when adding with rails 5 cart function, how to change only th
- how to check the production db with ruby on rails
- ruby on rails 5 - i want to get username when there are multiple treferences :user in my model
- ruby on rails - the list of posts on my page becomes the list of all posts
- ruby on rails - judgment of "there is no character string" in rails test
- ruby on rails - there is something i don't know about the association between models
- ruby on rails - i want to get the id of one of the posts lined up with each statement in rails
- ruby on rails 5 - how to check on the screen where the user must be logged in
- ruby - [rails] posts added to favorites are not saved
- ruby on rails - is there a way to change the screen and not clear the index screen?
- ruby on rails - i want to display in a list the posts that the user has liked
- ruby on rails - are there various ways to use tooltips?
- ruby - rails nameerror in postscontroller#create posts are not reflected
- ruby on rails - to check rails test data in csv before updating to db
- ruby on rails 5 - an error occurs if there is a form in form_with
- ruby on rails - what you need to know to understand aws
- ruby on rails - while creating an ec site with rails, an error nomethoderror in cartscontroller#add_item appears when trying to
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved