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 on rails 5 - an error occurs if there is a form in form_with
- ruby on rails - why there is no argument to edit or destroy in route in devise
- ruby on rails - associate users with posts with rails
- ruby on rails - to check rails test data in csv before updating to db
- ruby - posts of all users are included in the list of posts on rails my page
- ruby - rails nameerror in postscontroller#create posts are not reflected
- ruby on rails - regarding how to link categories and posts
- ruby on rails - the validation check error message in rails form_for is not displayed is it due to render?
- ruby on rails - there was an error parsing `gemfile` error with bundle install
- ruby on rails 5 - how to check on the screen where the user must be logged in
- ruby - [rails 5 practical guide: why can't i check the password_digest value]
- ruby - i can't save posts with form_with in rails 60
- ruby - how to check if rails server is started [rails]
- ruby on rails - use rails to arrange posts in order of preference for each group
- ruby - rails posts are not saved
- ruby on rails - judgment of "there is no character string" in rails test
- ruby on rails - when i start rails server, it says that there is no more space
- ruby on rails - i'll ask you about the error railsmissing required keys: [: id]
- ruby - i have a question on a rails learning course
- ruby on rails - about destroy command in rails
- 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
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- python 3x - import error "cannot import name '_imaging'"