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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:03:12+00:00 2026-05-19T05:03:12+00:00

Im receiving this error in my Rails app and cant find the solution. I

  • 0

Im receiving this error in my Rails app and cant find the solution. I will add some code from the class where it fails. It might be a more of an architectural problem if you think so please do say and I will add more code from other classes. I basically only have this model, and one controller and another class which is located in lib. An then a view of course. Thanks in advance!

  #app/models/news_api.rb
  require 'open-uri'

  class NewsApi
    URL = "http://www.mysomething.com/partner/api/1_0/somerandomnumber/
          channel/290/material/list/"

  def self.download
   new.document.css('news').map {|node| record(node) } 
  end

  def document
    Nokogiri::XML(open(URL)) 
    puts URL.to_s
  end

  def record(node)
    Story.new(node_to_hash(node)) 
  end

  def node_to_hash(node)
    Hash[Story::ATTRIBUTES.collect {|attribute| [attribute, text(node, attribute)] }]
  end

  def text(node, selector)
   node.css(selector).text
  end
end

@idlefingers: Here is the code from my view. What Im doing is basically using Nokogiri to parse some xml from an API and then displaying the response in HTMl in my view.

<ul id="news">
 <% @stories.each do |story| %>
 <li class=" <%= story.type_of_media %>">
  <h2><%= link_to story.header, story.url %></h2>
  <p class="permalink"><%= link_to 'Trackback', story.url %></p>
  <p class="meta">
    <strong><%= story.source_name %></strong>
    <br/>
    <%= story.created_at %>
    <br/>
    <%= story.geo %>
  </p>
  <p class="summary"><%= story.summary %></p>
 </li>

<% end %>

  • 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-19T05:03:12+00:00Added an answer on May 19, 2026 at 5:03 am

    Where is the error coming from? At a glance, it looks like it’s coming from the .document method, but it isn’t clear. Can you add the error backtrace?

    The .document method as it stands will be returning the result of puts URL.to_s, which will be nil. You just need to switch around the two lines in your .document method by the looks of it…

    def document
      puts URL.to_s
      Nokogiri::XML(open(URL)) 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm receiving this error on my jsp file - 'Can not find the tag
I am currently receiving this error: Validation of viewstate MAC failed. If this application
I am not sure what the problem is but I keep receiving this error
I'm building a rails app that takes information about products from an XML datafeed
This one has got me stumped. I'm deploying a Rails 3 app to Slicehost
I am receiving this error: File /DateDbLoop.py, line 33 d.Id % (str(day), str(2840)) ^
I am receiving this error: The ViewData item that has the key 'DepartmentId' is
I'm receiving an error while trying to install a gem called typhoeus (this is
Receiving this error: a different object with the same identifier value was already associated
hi i'm receiving this error Notice: Undefined index: SESSION_ADMIN_MEMBER_TYPE in ... how do I

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.