Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Installation and setup #20

Closed
fenelon opened this Issue · 6 comments

2 participants

@fenelon

Hi,

I'm really sorry for such a question, but I can't get happymapper to work =(

I'm currently using 3.1 and that's what I did:

1) Added gem 'happymapper' to gemfile and Bundled it
2) Inside my controller file added these two:

class Reference
  include HappyMapper
  element :listName, String
  element :itemCount, Integer
end

class Item
  include HappyMapper
  element :id, Integer
  element :name, String
end

3)Then, in my controller action:

    file_contents = File.read('tmp/spo.xml')
    refs = Reference.parse(file_contents)
    @id = refs.item.first.id
    @name = refs.item.first.id

4) It throws uninitialized constant Reference::HappyMapper

PS I also tried to require it, but it says no such file to load -- happymapper

Thanks a lot! Great job!

@jnunemaker
Owner
@fenelon

yes, and bundled it.

@jnunemaker
Owner
@fenelon

Oh, yeah. =) I misspelled the restart command for POW. Sorry for that.
Thank you for such a great gem!

@fenelon

Now I'm getting
undefined method `parse' for HappyMapper::Item:Class

Thank you so much for your help!

class Reference
  include HappyMapper
  has_many :items, Item
  
  element :listName, String
  element :itemCount, Integer
end

class Item
  include HappyMapper
  
  element :id, Integer
  element :name, String
  
end

and in controller:

  def xml1
    file_contents = File.read('tmp/spo.xml')
    refs = Reference.parse(file_contents)
    @id = refs.items.first.id
    @name = refs.items.first.name
  end
@fenelon

RESOLVED:

The class names in associations must be quoted
has_many :items, 'Item'

Not clear why examples work.

@jnunemaker jnunemaker closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.