S
Samantha
Long time no see!
Hopefully I can get some insight into something I'm dealing with, as I
have in the past!
I'm working on something in Rails, however, I believe this to be more
of a Ruby question than anything having to do with Rails.
I'm grabbing all the associations from a Class, and then putting those
associations into an Array. What I get back is an Array of symbols.
Now, I need to do the same thing for those symbols... however, I need
to somehow get Ruby to recognize those symbols as Classes.
So, let's say in my array, I have a symbol by the name of :foos, that /
should/ correspond with the Foo class.
So...
array looks like: [:foos, :bars]
I need to be able to do something along the lines of:
array[0].to_s.capitalize.singularize.my_method_to_grab_associations
Well, obviously that will give me Foo, but it thinks Foo is a string.
Which leads me to my question -
How do I get my method to give me back what I'm looking for on Foo,
rather than complaining that Foo is a string?
Thanks in advance!
Hopefully I can get some insight into something I'm dealing with, as I
have in the past!
I'm working on something in Rails, however, I believe this to be more
of a Ruby question than anything having to do with Rails.
I'm grabbing all the associations from a Class, and then putting those
associations into an Array. What I get back is an Array of symbols.
Now, I need to do the same thing for those symbols... however, I need
to somehow get Ruby to recognize those symbols as Classes.
So, let's say in my array, I have a symbol by the name of :foos, that /
should/ correspond with the Foo class.
So...
array looks like: [:foos, :bars]
I need to be able to do something along the lines of:
array[0].to_s.capitalize.singularize.my_method_to_grab_associations
Well, obviously that will give me Foo, but it thinks Foo is a string.
Which leads me to my question -
How do I get my method to give me back what I'm looking for on Foo,
rather than complaining that Foo is a string?
Thanks in advance!