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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:26:44+00:00 2026-05-12T22:26:44+00:00

I am trying to use hpricot in JRuby. My problem is the following. If

  • 0

I am trying to use hpricot in JRuby.
My problem is the following. If I have this code:

 #!ruby
 require 'hpricot'
 require 'open-uri'
 # load the RedHanded home page
 doc = Hpricot(open("http://redhanded.hobix.com/index.html"))

where do I put it?
Into my controller? Because its not accepting it there.
And if I’m supposed to put it in my model. How can I call it frm my view?

Thank you

it gives me this error when trying the wired.com website

Errno::ENOENT in
ProductsController#create

No such file or directory – File not
found – http://www.wired.com

RAILS_ROOT: H:\Documents and
Settings/owner/My
Documents/NetBeansProjects/RailsApplication5

  • 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-12T22:26:44+00:00Added an answer on May 12, 2026 at 10:26 pm

    Getting Rails to understand and see Hpricot is not very hard to do.

    1. Install Hpricot: jruby -S gem install hpricot.
    2. In your Rails app, find the config/environment.rb file
    3. Find the lines which start with config.gem in the file and add

      config.gem "hpricot", :source => "http://code.whytheluckystiff.net"

    4. Now you’ll be able to use Hpricot directly from a controller as in normal (J)Ruby code. I strongly advise not to put any kind of business logic into your views and only minimal conditionals for sanity and in order to keep things straight, readable and maintainable. Or if you follow the “skinny controllers, simple views, fat models” paradigm, you may be able to refactor the code and put the Hpricot calls directly into a method inside your model class that is accessible from the view.

    Some code examples are below.

    Example controller RAILS_ROOT/app/controllers/example_controller.rb:

    class ExampleController < ApplicationController
      def index
        @doc = Hpricot(open("http://www.wired.com"))
        # here come some very serious calculations, queries etc.
      end
    end
    

    Example view RAILS_ROOT/app/views/example/index.html.erb using the controller:

    <pre>
      <%= @doc ? @doc.to_s : "There is no content at the site" %>
      <!-- blablabla -->
    </pre>
    

    As I’ve mentioned, you might be able to push the Hpricot(open(...)) call back to the model, but first give it a try like this. If it’s working, refactor 🙂

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

Sidebar

Related Questions

Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
i'm trying use webview to load a image from sdcard i use this path
I am trying use Thread but i have some problem (I am beginner at
Trying to use the getDependentRowset in a ZF application. I have the following relationship
I am trying use neo4j with Ruby on rails on Mac OSX. I have
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Hi I'm trying use a datepicker on a field I have. I'm trying to
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
trying to use this route: from(activemq:profiles).aggregate(header(cheese)).batchSize(30).bean(ProfilesQueueService, saveContacts) Fails with: No signature of method: org.apache.camel.model.RouteType.aggregate()

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.