small medium large xlarge

11 Apr 2008, 08:37
Bishnu Prasadit pradipta Narayan Das (1 post)

Hi all

  **--my problem is that i get key and value .but i have to save in the data base   in a generic ways.My code is like this:-

local_keys = @params.keys first_addition = true param_value =0 for key in 0…local_keys.length list=key.methods key_name = local_keys[key] value = @params[key_name] puts “key “+key_name.to_s+ “ value “+value.to_s if key_name!=”action” && key_name!=”controller” @test_runs = @test_run.ks=value(it is successful)(here ks is my column name) but i want to save in a generic ways. like
@test_runs.key_name= value.(it is not working )

can i do it in a generic way.if anybody knows please help me in this regard.but any how i got all the keys and values .only my problem is how i assignn each key to should be in genric way.i have search it but i do not get the right way.

23 Apr 2008, 19:56
Sam Ruby (634 posts)

Try @test_runs.instance_variable_set("@#{key_name}", value)

You must be logged in to comment