···
------------------------------------------------------------
database_columns=['ExternalRef', 'Originator', 'Responder', 'Title',
'Category', 'Location', 'Observation',
'Recommendation','Concern','Document_id', 'OriginatorRef']
session_db_array=[1,3,4,5,6,7,9]
myhash = {}
db_columns.each_with_index{|k,i|myhash[k] = data_save_array[i] }
# This is the hash of selected db columns and their corresponding values
rid = Rid.new myhash
rid.date = Time.new
rid.workflow = 0
rid.project_id = session[:projectid]
rid.save
------------------------------------------------------------------------
But the problem is that
My hash values do not correspond to my sql query
eg: In my hash
"Originator"=>" J FABRE 2 originator"
But in my insert query
Originator = 0
------------------------------------------------------------------------
puts(myhash.inspect) value
{"Originator"=>" J FABRE 2 originator", "Title"=>"Element development
plan", "Category"=>"major category", "Location"=>"prob loca08.01.2012",
"Observation"=>"2.0", "Recommendation"=>"add GACF milestone in schedule
section 6.3", "Document_id"=>"Element development plan"}
------------------------------------------------------------------------
INSERT INTO `rids` (`ExternalRef`, `Originator`, `Responder`, `Title`,
`Category`,
`Location`, `Observation`, `Recommendation`, `Conclusion`, `Response`,
`InternalState`, `InternalDate`, `ExternalState`, `MeetingReference`,
`Disposition`,
`DispositionState`, `Concern`, `Requirement_id`, `Ridresponse_id`,
`Document_id`,
`project_id`, `date`, `closuredate`, `workflow`, `OriginatorRef`,
`Implementation`, `implemented_on`, `implemented_by`, `closed_comment`)
VALUES(NULL, 0, 0, 'Element development plan', 0,
'prob loca08.01.2012', '2.0', 'add GACF milestone in schedule section
6.3', NULL, NULL,
0, NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL, 0,
20, '2012-07-17 15:51:11', NULL, 0, NULL,
NULL, NULL, NULL, NULL)
--
Posted via http://www.ruby-forum.com/.