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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:21:26+00:00 2026-05-20T01:21:26+00:00

I have partial view that displays model-specific flash messages. The partial looks like: app/views/mymodel/_flashpartial.erb

  • 0

I have partial view that displays model-specific flash messages. The partial looks like:

app/views/mymodel/_flashpartial.erb

<% flash.each do |key, value| %>
  <% if model_key = myModelFlash(key) then %>
    <%= content_tag(:div, value, :class => "flash #{model_key}") %>
  <% end %>
<% end %>

The myModelFlash method simply takes the key and checks for a particular prefix using a simple regex. It’s located in

app/helpers/mymodelhelper.rb

module MyModelHelper
  def myModelFlash( key )
    m = /^_mymodel_(.*)/.match(key)
    m[1] unless m.nil?
  end
end

This works perfectly fine in my development and test environments. As soon as it goes onto Heroku, I get an error saying (ActionView::Template::Error) “can’t convert Symbol into String” pointing to the call to match.

If I remove the call to myModelFlash from the view and simply display the key and value, that works just fine in terms of not erroring out, so at the very least the key and value are getting into the partial view just fine. For some reason the helper method thinks that the key being passed into it is a symbol and not a String.

Any ideas as to why this might be happening?

  • 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-20T01:21:27+00:00Added an answer on May 20, 2026 at 1:21 am

    I suggest you just use key.to_s as a quick workaround.

    The reason for your problem may be that some version of some component differs between your testing server and the production server.
    If your tests pass, and your production environment crashes, that is a very bad situation.

    You should compare the versions of ruby and all of the gems you are using. If you use ‘bundler’ then ‘bundle list’ gives a nice summary.

    If you find out that all the versions are the same… Well, we will be looking for another reason.

    Update

    As it seems that the problem is caused not by the version differences, but by unexpected data in flash, which obviously in production environment may be different than in testing.

    I suggest you change the myModelFlash method a little.

    def myModelFlash( key )
      if m = /^_mymodel_(.*)/.match(key.to_s)
        return m[1]
      end
    end
    

    The flash may contain different keys, some of them may be Symbols or really anything, so you must be prepared to handle all of them.

    Converting the key parameter with .to_s should be a safe choice, but if you are sure that you always set the flash keys (I mean the keys related to this “_mymodel” issue) as Strings, you may change the first line of this method:

    def myModelFlash( key )
      if key.is_a?(String) && m = /^_mymodel_(.*)/.match(key.to_s)
        return m[1]
      end
    end
    

    And in your test, add a few other keys to your flash, and then test how the action handles them.

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

Sidebar

Related Questions

I have an MVC view with a partial view recursive call that displays hierarchical
I have a partial view that shows a list of Categories . I'd like
I have a control that is created like so: public partial class MYControl :
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
I have taken on an MVC project that has a view that displays several
I have a number of pages that include the same partial view which contains
I have a partial view that uses a Telerik MVC Grid, and it has
I have a partial view that renders a list of objects into a table
I have a partial view that is a search textbox and button. I am
I have a partial view that I am using from 2 different forms. In

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.