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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:31:04+00:00 2026-05-29T23:31:04+00:00

i have a shared template that i use regularly to show errors like :

  • 0

i have a shared template that i use regularly to show errors like :

 <%= render "shared/flash_error", :error => flash[:error], :info => flash[:info] %>

This variables are optional, so my view is like :

<% if defined?(error) and error %>
    <div class="error">
        <%= error %>
    </div>
<% end %>

<% if defined?(info) and info %>
    <div class="info">
        <%= info %>
    </div>
<% end %>

Now, there are cases when i would need to add a new optional variable and extend the partial with other types of errors. This, however, can make the rendering hard to keep up with. I would now need to edit every render and change it to :

<%= render "shared/flash_error", :error => flash[:error], :info => flash[:info], :new_entry => flash[:new_entry] %>

and so on with every new entry. So, i am wondering, is there a way for the rendered partial to ‘observe’ specific flash variables,so that i don’t even have to pass them as attributes to the rendered view ?

  • 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-29T23:31:05+00:00Added an answer on May 29, 2026 at 11:31 pm

    Yeap, tried it and works fine. Something like :

    <%= render "shared/flash_error", msg_notifications %>
    

    where msg_notifications is just a hash filled with everything, so it can be changed in a DRY way. Simple, yet sometimes the mind plays bad games 😛

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

Sidebar

Related Questions

I have a shared library that I wish to link an executable against using
I have an editor template (Views/Shared/EditorTemplates/HORDER.ascx) which inherits System.Web.Mvc.ViewUserControl<CCOK2.Models.HORDER> My viewmodel has a one-to-many
I have an shared object that need to be send to a system API
I have a few objects that are incredibly similar. In fact, they use STI
I have a class that requires a boost::variant containing shared pointers to various types
I have a template function that I wish to return either the type of
I have been using a variadic template that acts as an exception firewall in
I'm running Sitecore 6.5 and have a data template that has an image field
I have some code that I am retrofitting to use an allocator instead of
I have a class that does a transformation on a string, like so class

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.