Hello,
I don''t know what the Rails multidimensional array structure is and I
am
having a problem in this regard.
Basically we have a set of games and in a XMLFEEDS table we have basic
information about the games (the game date, the sport type of the game).
Then in the PARTS table, we have two entries per xmlfeed entry which
correspond to the two teams participating in the game.
Essentially, right now I have a line in my code that goes like this:
@local_lines1 = Xmlfeed.find(:all, :conditions => ["id = ?", @id])
This is guaranteed to give me exactly one row from the database and as
such, am able to make a call like this:
@visiting_team = @local_lines1[0].parts[1].participant_name
where the xmlfeeds table and the parts table have been linked in a model
somewhere. I am able to just reference the zeroth element of the
@local_lines1 variable since I know that there is only 1 row that is
being selected from the database call.
But now I want to store all of the data from the xmlfeed in a session
variable so I do this:
session[:lines] = Xmlfeed.find(:all);
But this now should be a multidimensional array of data since there are
multiple rows being selected.
My question is, how do I again get that row that corresponds to the @id
variable so that i can access all data corresponding to that row?
I have tried simply doing this:
@local_lines1 = session[:lines].select {|record| record.id == @id}
which I think should give me the one row that I want, but then when I
try to access, for example, the visiting them the way I previously tried
(i.e. @local_lines1[0].parts[1].participant_name), my application fails.
I hope this wasn''t too confusing! If anyone has any ideas, I would
greatly appreciate it.
Thank you so very much ahead of time for your help.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---