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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:37:05+00:00 2026-05-23T17:37:05+00:00

Context: I am really scratching my head with this one, I’ve had a look

  • 0

Context: I am really scratching my head with this one, I’ve had a look at other code to see how this is done. I appreciate this is a fundamentally simple part of coding. To be honest up until now I’ve probably overused class methods, but self.attrib = x doesn’t work with class methods. Anyway, my problem.

I have this in my model:

  def self.get_user
    @people = Person.where(:mp => nil)
    @people.each do |person|
      person.get_link(person.postcode)
    end
  end

  def get_link(postcode)
    base = "http://news.bbc.co.uk/democracylive/hi/search?q="
    postcode = postcode
    target = "//a[starts-with(@class, 'name')]  /@href"
    url = base + postcode
    page = Nokogiri::HTML(open(url))
    mps = []
    page.xpath(target).each do |node|
      mps << node.text
    end
    link = mps[0]
    self.get_email(link, postcode)
  end

Now the person.get_link(person.postcode) part throws up a no method found error in the console :/ I literally don’t understand why, its clearly there. The only thing I can think of is that the data type is incorrect – problem is I don’t know how to correct that.

Really appreciate any pointers.

(Note: I know that method might not be the best it can be, I’m a bit of a noob but am getting there – slowly but surely 🙂 )

EDIT: ADDED STACK TRACE

NoMethodError: undefined method get_link' for #<Person:0x103633cc0>
from /Library/Ruby/Gems/1.8/gems/activemodel-3.0.7/lib/active_model/attribute_methods.rb:367:in
method_missing’
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/attribute_methods.rb:46:in method_missing'
from /Users/geoff/RailsWork/mpmail/app/models/postcode.rb:8:in
get_user’
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/relation.rb:13:in each'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/relation.rb:13:in
send‘
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.7/lib/active_record/relation.rb:13:in each'
from /Users/geoff/RailsWork/mpmail/app/models/postcode.rb:7:in
get_user’
from (irb):2

  • 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-23T17:37:05+00:00Added an answer on May 23, 2026 at 5:37 pm

    You are calling the get_link method on the Person class while you defined it in the Postcode class, if I’m reading your stacktrace correctly. Move get_link to the Person-class and see what happens.

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

Sidebar

Related Questions

Hi folks would really appreciate your help in answering this rather involved question. Please
Context PHP 5.3.x Overview After doing a code-review with an associate who uses both
Some context: one of the systems I'm working on is a .net 2.0 web
I was reading this article by Brandon Aaron here , about how jquery context
I'm finding it really annoying to have to disassemble large swathes of library code
I'm not really sure why i do not have access to the @date (this.date)
No issues really, this is more for my personal comprehension. Using MVC3 + EF
Context: I'm in charge of running a service written in .NET. Proprietary application. It
Context: So, I am attempting to build a ridiculously complex domain model. Talking with
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp

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.