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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:49:42+00:00 2026-06-04T14:49:42+00:00

This code in helper: def dgtags if params[:controller]==’my_controller’ javascript_include_tag(‘dygraph-combined.js’) << tag(:meta, :http_equiv => ‘X-UA-Compatible’,

  • 0

This code in helper:

def dgtags
    if params[:controller]=='my_controller'
      javascript_include_tag('dygraph-combined.js') <<
          tag(:meta, :http_equiv => 'X-UA-Compatible', :content => 'IE=EmulateIE7; IE=EmulateIE9') <<
          '<!--[if IE]>'.html_safe <<
          javascript_include_tag('excanvas.compiled.js') <<
          '<![endif]-->'.html_safe
    end
end

produces following output:

<script src="/javascripts/dygraph-combined.js?1338036501" type="text/javascript"></script><meta content="IE=EmulateIE7; IE=EmulateIE9" http_equiv="X-UA-Compatible" /><!--[if IE]><script src="/javascripts/excanvas.compiled.js?1237712986" type="text/javascript"></script><![endif]-->

How to insert line breaks between tags? Like this:

<script src="/javascripts/dygraph-combined.js?1338036501" type="text/javascript"></script>
<meta content="IE=EmulateIE7; IE=EmulateIE9" http_equiv="X-UA-Compatible" />
<!--[if IE]><script src="/javascripts/excanvas.compiled.js?1237712986" type="text/javascript"></script><![endif]-->

The ‘\n’ or ‘\n’.html_safe does not help – it produces literally \n.

  • 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-04T14:49:44+00:00Added an answer on June 4, 2026 at 2:49 pm

    You have to use double quotes "

    Use "\n" not '\n'

    You can get more detailed information here: http://en.wikibooks.org/wiki/Ruby_Programming/Strings

    I have changed your code a bit. Better approach is to join all elements using "\n". Also you can use controller_name instead of params[:controller].

    def dgtags
        if controller_name == 'my_controller'
          [ javascript_include_tag('dygraph-combined.js'),
            tag(:meta, :http_equiv => 'X-UA-Compatible', :content => 'IE=EmulateIE7; IE=EmulateIE9'),
            '<!--[if IE]>',
            javascript_include_tag('excanvas.compiled.js'),
            '<![endif]-->'].join("\n").html_safe
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this Ruby code: Module M Class C < Struct.new(:param) def work M::helper(param) end
My helper code looks like this (and works fine btw): module ProvidersHelper def call_to_review(provider)
I have this code : def create login(params[:email], params[:password]) if current_user flash[:notice] = Welcome
How can I define admin_user if I have this code in my controller: def
I have this in my application_helper.rb : def bbcode(text) # Code snippets text.gsub!(/\[code=?[']?(.*?)[']?\](.*?)\[\/code\]/mis) {
I wrote my code using this article at msdn as a primary helper My
Controller: class SessionsController < ApplicationController layout 'login' def create user = login(params[:username], params[:password]) if
I have the following code inside a helper in rails: def custom_options_tag(opts={}) ['am', 'pm'].each
I'm trying to compile the following code: class MyClass { def foo(): this.type =
I'm trying to do this in a helper: def radio_button_by_code(da_form, da_field, product_id, option_code) txt

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.