The params' hash keys are mix of camelcase, lowercase and uppercase characters:
params = {"RefreshTime"=>"0", "lang"=>"tr", "amount"=>"50", "ACQBIN"=>"490740"}
The array, which is a list of one of my models' column names, is all lowercase but exactly the same values with the keys of params hash =>
columns = ["refreshtime", "lang", "amount", "acqbin", ......]
I'm trying to match hash keys with the members of the array to create a new record in my controller =>
def create_transaction
@transaction = OrderTransaction.new(
params.each do |k, v|
columns.each do |i|
if i == k.downcase
"#{i}: params[:#{k}],"
end
end
end
)
end
But this piece of code isn't working as I expected. It seems like I'm doing something wrong in the line of;
#{i}: #{v}
What am I missing here?
By the way, this was my old way to do this job, which causes many lines of code =>
@transaction = OrderTransaction.new(
refreshtime: params[:RefreshTime],
lang: params[:lang],
amount: params[:amount],
acqbin: params[:ACQBIN],
...
)
amount: params[:amount]in that linekis aStringand not aSymbol?i == kis not going to be correct in any case.