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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:11:15+00:00 2026-05-24T09:11:15+00:00

Useful additional info: I am using the decent_exposure gem so this might be the

  • 0

Useful additional info: I am using the decent_exposure gem so this might be the issue – correcting the code below:

expose(:get_filter_tags) do
  if params[:filter_tag_names]
    filter_tag_names = Array(params[:filter_tag_names].split(" "))
    filter_tags = Array.new
    filter_tag_names.each do |f|
      t = Tag.find_by_name(f)
      filter_tags << t
    end 
  end
end

So, something funny happens when I call this in the view:

query string ?utf8=✓&filter_tag_names=test

<% get_filter_tags.each do |ft| %>
  <%= ft.name %> 
<% end %>

Error message: undefined method `name’ for “test”:String

Why is this trying to call name on a string not a Tag object? If I put the following in the view, and have jut one filter_tag_names item

def getfiltertag
  Tag.find_by_name(params[:filter_tag_names]) 
end

#view
<%= getfiltertag.name %>

query string: ?utf8=✓&filter=test

like above then I can call name just fine, so obviously I am doing something wrong to get an array of strings instead of objects. I just don’t know what. Any suggestions?

  • 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-05-24T09:11:16+00:00Added an answer on May 24, 2026 at 9:11 am

    Your problem is that each returns self — so if you write filter_tag_names.each, it returns filter_tag_names. You could fix this by explicitly returning filter_tags, but more idiomatically, you could just rewrite it as:

    expose(:get_filter_tags) do
      if params[:filter_tag_names]
        filter_tag_names = Array(params[:filter_tag_names].split(" "))
        filter_tag_names.map {|f| Tag.find_by_name(f) } 
      end
    end
    

    Just as an aside, this method will return nil if there aren’t any filter tag names. You may want to do that, or you might want to return an empty collection to avoid exceptions in the calling code.

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

Sidebar

Related Questions

Using the below code, the issue is I have two buttons and two textfields
Using the below code, but I am not getting the value of result in
What tools are useful for automating clicking through a windows form application? Is this
MySQL has this incredibly useful yet proprietary REPLACE INTO SQL Command. Can this easily
Sometimes it might be useful, but mostly just looking cool or impressive to visualize
pre tags are super-useful for code blocks in HTML and for debugging output while
I'm attempting to install the 'mysql2' gem on my production server using Capistrano. I
I am using back camera to read bar code data...and it is scanning perfectly.Now
Someone told me about swamp diagrams explaning that they were useful to predict code
I have a C++ dll reporting lots of useful information via console output using

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.