Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:43:00+00:00 2026-06-10T22:43:00+00:00

form that causes the problem: <%= form_for Like.find(post.user.likes), :html => { :method => :delete

  • 0

form that causes the problem:

<%= form_for Like.find(post.user.likes), :html => { :method => :delete , :class => "unlike_post_like_form" } do |f| %>

Post model

belongs_to :user
has_many :likes

User model

  has_many :posts
  has_many :likes

Like model

  belongs_to :post
  belongs_to :user

i keep getting the following error:

TypeError in Users#show 
Cannot visit Like

on

Like.find(post.user.likes),

EDIT:

First solution:

changing

Like.find(post.user.likes),

to

Like.find(post.user.likes).limit(1),

Second solution:

changing

Like.find(post.user.likes),

to

current_user.likes.where(:post_id => post.post_id)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:43:02+00:00Added an answer on June 10, 2026 at 10:43 pm

    Like.find(post.user.likes) is attempting to find a Like given an array of likes. That doesn’t really make much sense.

    Most likely, you’ll want to search post.user.likes, but even then, I’m a bit confused – you’ll need to post more code.

    Like.find is looking for either an id (integer), or a hash containing keys and values. An array doesn’t give it any information to search.

    EDIT: If you’re looking for the likes of current user. You’ll need to do the following…

    current_user.likes.where(:post => @post)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to
I have a HTML form that has certain fields which i am opening inside
I have a form that has label values that I would like to pass
I have a form that the user submits and returns a result, but it
I have a dynamic form that users can add/delete sets of input fields. I
Server is PHP5 and HTML charset is latin1 (iso-8859-1). With regular form POST requests,
If you post a html form with inputs having names ending with [], php
At present the search form is for last name only and that causes problems
I have a form that I'm submitting through AJAX. The form includes many fields,
I have a form that I want to be validated before showing it initially.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.