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

  • SEARCH
  • Home
  • 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 8180855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:19:55+00:00 2026-06-07T00:19:55+00:00

I have a data model where a User can like a Project, Suggestion, Comment

  • 0

I have a data model where a User can like a Project, Suggestion, Comment, or other objects.
The models are set up correctly, and likes/show.rabl works if we were just to support the Project child

object @like
attributes :id, :created_at, :target_type, :target_id, :user_id
child :user => :user do
  extends "users/show"
end
child :target do
  node do |project|
    partial('projects/show', :object => project)
  end
end

However, I want to be able to use partials of suggestions/show, comments/show as well depending on target_type.

I tried this but it’s not working:

child :target do |u|
  u.target.map do |r|
    if r.is_a?(Suggestion)
      partial("suggestions/show", :object => r)
    elsif r.is_a?(Project)
      partial("projects/show", :object => r)
    end
  end
end

I get undefined method target for <Rabl::Engine:0x69fb988>. However, I don’t get this error in the first case. Any ideas?

  • 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-07T00:19:57+00:00Added an answer on June 7, 2026 at 12:19 am

    Have you tried using extends instead of partial?

    Perhaps you could try something like this?

    child :target do |u|
      u.target.map do |r|
        if r.is_a?(Suggestion)
          extends "suggestions/show"
        elsif r.is_a?(Project)
          extends "projects/show"
        end
      end
    end
    

    In this case, when you use extends, you don’t need to pass in an :object because you’re already in the scope of iterating through with the object r.

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

Sidebar

Related Questions

I have a data model object User . My app also has some other
I have multiple models like this: class Model1(models.Model): user = models.ForeignKey(User) model1_filed1 = models.CharField()
I currently have two Backbone models: user and project. I would like to have
I have a rails application with User and Machine data models, as well as
I have a simple data model of two tables, email and recipients, email can
I have a PaartialView declared like this: @model IEnumerable<mvc1.Models.ProjectDetailModel> @using (Html.BeginForm()) <form method=get action=EditProject
I have ArtistProduct model. User enters the product details, user can view the entered
In a webapp, i have a data-model (let's call it Item). The data of
I have an Entity Data Model that I have created, and its pulling in
I have made a data model, and now I've made a 2nd version. All

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.