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 8849055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:33:05+00:00 2026-06-14T12:33:05+00:00

Use acts-as-taggable-on for tagging. Based previous questions in SO i read that i must

  • 0

Use acts-as-taggable-on for tagging. Based previous questions in SO i read that i must minimize logic in the view and create a helper for conditions in the view template. Here’s my code so far. (newby rails)

Routes:

resources :appartments do
  collection do
    get ':tag', to: 'appartments#index', as: :tag
    end

My controller:

def index
    if params[:tag]
            @apartments = Appartment.tagged_with(params[:tag])
            else
            @apartments = Appartment.all
            end
    end

Application helper:

def render_partials_conditionally
        if @apartments.include?("family")
            render :partial => 'familie'
            if @apartments.include?("groups")
            render :partial => 'groups'
        end
    end
end

The idea (i assume) is that i check if the value “familie” exist in the @apartments array with the include? method

Apartment index view

 = render_partials_conditionally   

When i go to apartments/family the partial _family must showed, but nothing happens…no error, no partails

What am i doing wrong?

Grtz..remco

  • 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-14T12:33:06+00:00Added an answer on June 14, 2026 at 12:33 pm

    If Appartment is a model, @apartments should be an array of objects, so @apartments.include?("family") and @apartments.include?("groups") will never be true.
    Instead, the code could be like this:

    @apartments.any? { |apartment| apartments.some_field == "groups" }
    

    However I think it is still not good enough. A better approach could be that the helper only return the name of the partial, and then render the partial in view.

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

Sidebar

Related Questions

I use acts-as-taggable-on https://github.com/mbleigh/acts-as-taggable-on for tagging user's post, I want to find one user's
I want to use acts-as-taggable-on gem for my rails app. (rails 3.0.10 and ruby
In C++11 you can use a range-based for , which acts as the foreach
Am using below specified gem acts-as-taggable-on(2.2.2) will_paginate(3.0.2) rails(3.0.3) ruby 1.8.7 i tried to use
I want to create an object that acts as a specific class, such as
I've implemented the framework outlined in this post: How to use jquery-Tokeninput and Acts-as-taggable-on
I'm using acts-as-taggable-on in my application and I want to be able to use
I use acts-as-taggable-on gem and would like to fetch 5 most used tags, how
Using FCKeditor (2.6.5) When I use the upload feature it acts as if it
I need a simple table that acts as a Queue. My MySQL server restriction

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.