Vrishali
(Vrishali....)
March 11, 2009, 5:48am
1
Hi evrybody..
I was storing the values in hash using..
places = [
{:address=>'555 Irving, San Francisco,
CA',:description=>'Irving',:image=>'/images/1.jpg'},
{:address=>'1401 Valencia St, San Francisco,
CA',:description=>'Valencia',:image=>'/images/2.jpg'},
]
But now I want to take these values from database..I created ,
migrated table correctly...
N now using the statement
@companies = Company.find(:all)
But now i dont understand how can i store these fetched values in hash-
'places'
I dont want static values...
So can anybody please help me for it...
Thanks...
Vrishali
(Vrishali....)
March 13, 2009, 11:28am
2
Thanks for the help...
actually i am using places hash evrywhere....so i dnt want
modifications throughout the code...n files...so..i want to put the
all retrieved records to be placed in that...places.
n i want it at the start of controller call...
thats y...
ok i tried ur statments given...but still it is giving error...
TypeError in GmapController#index
can't convert nil into String
RAILS_ROOT: /home/ubuntu/gmaptry
Application Trace | Framework Trace | Full Trace
app/controllers/gmap_controller.rb:57:in `+'
app/controllers/gmap_controller.rb:57:in `get_geocode'
app/controllers/gmap_controller.rb:30:in `index'
app/controllers/gmap_controller.rb:28:in `each'
app/controllers/gmap_controller.rb:28:in `each_with_index'
app/controllers/gmap_controller.rb:28:in `index'
....
so what should i do...please help....
also i am using evrywhere....
place[:address]
place[:description]....
so how can i specify that...
please help me....
thanks...
Vrishali
(Vrishali....)
March 13, 2009, 12:48pm
3
ok...
I got the solution by myself
now i am using the code...
@companies.each do |company|
places [ {:address => company.addr, :description =>
company.cname , :image => company.img}]
end
it is working without ant error...
but now the problem is that .....
the values are getting overwritted in places array...and only last
record is saved...
so what can i do for increamenting places index...
or anybody knows any another method....
please help me....