I'm new to ruby on rails, on this project I'm using Ruby 2.0 and Ruby on Rails 3.0.
I would like to know if this piece of code can be refactored, as it is
unless params["ot_code"].nil?
ots = params["ot_code"].gsub(/\r\n?/, "").gsub(";","','").upcase
ots[ots.length,1] = "'"
ots = ots.rjust(ots.length+1,"'")
end
unless params["circuit_id_multiple"].nil?
multiple_circuit = params["circuit_id_multiple"].gsub(/\r\n?/, "").gsub(";","','")
multiple_circuit[multiple_circuit.length,1] = "'"
multiple_circuit = multiple_circuit.rjust(multiple_circuit.length+1,"'")
end
unless params["multiple_element_code"].nil?
multiple_element_code = params["multiple_element_code"].gsub(/\r\n?/, "").gsub(";","','")
multiple_element_code[multiple_element_code.length,1] = "'"
multiple_element_code = multiple_element_code.rjust(multiple_element_code.length+1,"'")
end