0

I'm trying to read this array on RoR:

> importer_name = [#<RouteImporter id: 1, name: "aa", filename: "aa1", type: "RouteImporter">]

I just want to get the filename character "aa1", I tried with importer_name[2] but I didn't get nothing and I don't want 'filename: "aa1"' I just want "aa1", any idea? Thanks in advance!

1
  • Can you give us a little bit more code? How do you create that RouteImporter object for example? Commented Nov 13, 2012 at 10:48

1 Answer 1

2

you have a Ruby object stored in an array. You can access it like this(If I understand you correctly):

importer_name.first.filename
Sign up to request clarification or add additional context in comments.

1 Comment

it works! Now I would like to make a require of importer_name.first.filename, but I get this error: cannot load such file -- aa1 RouteImporte inherits from Importer. class Importer < ActiveRecord::Base attr_accessible :name, :filename, :type set_inheritance_column :type end. class RouteImporter < Importer end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.