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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:16:31+00:00 2026-05-31T02:16:31+00:00

in my data_feed controller and bar action, there’s only one line in bar.html.erb: [1,2,3,4]

  • 0

in my data_feed controller and bar action, there’s only one line in bar.html.erb:

[1,2,3,4]

My expected output by requesting http://localhost:3000/data_feed/bar is just one line I wrote above.

However, rails help me add some html heads into that page, as below:

<!DOCTYPE html>
<html>
<head>
<title>Guustock</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/charts.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/data_feed.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/show.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/charts.js?body=1" type="text/javascript"></script>

<script src="/assets/data_feed.js?body=1" type="text/javascript"></script>
<script src="/assets/show.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="lhHWCW82xtqQ8fmgBZemDggL2DGJe+4chXM8MY1LKvs=" name="csrf-token" />
</head>
<body>
[1,2,3,4]

How can I avoid rails doing this?
Thanks!

Env:
linux mint 11.0
ruby 1.9.3 with rvm
rails 3.2.1

EDIT:

Actually I want to provide the json format data in this page as an ajax data source. So these heads will not helpful but break the data.

  • 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-31T02:16:32+00:00Added an answer on May 31, 2026 at 2:16 am

    You’re probably rendering within the layout (a view template, which lives in app/views/layouts/), which is the default. If you want to render an action without the layout, use something like

    render :bar, :layout => false
    

    in the appropriate action.

    See also: http://guides.rubyonrails.org/layouts_and_rendering.html

    EDIT:

    Please see the documentation linked above. For JSON rendering, you might use this directly from the controller:

    render :json => @product
    

    or in your case

    render :json => [1,2,3,4]
    

    You could also use JSON view templates (for which you’ll need to render again). Using a bar.html.erb template for json is not only tricky as you noticed, it will also produce the wrong content type headers.

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

Sidebar

Related Questions

So below is my code for my controller, which I have four of one
M(model): HTML, V(view): CSS, C(Controller): JavaScript Hi, I'm maintaining a personal bookshelf (a list
Avoiding Fat Controller So I'm using Zend Framework and I have a question involving
I am using back camera to read bar code data...and it is scanning perfectly.Now
So basically I have just benchmarked my update_feeds controller and found that the amount
I have a data feed continuously feeding data packet in. There are 5 threads(A,
There is a data feed server receives feed from various clients by means of
I have an iPhone app (in XCode 4) that uses the standard Tab Bar
I have a Controller method that needs to accept multipart/form-data sent by the client
I'd like to know where the controller gets the user input from (to feed

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.