Greetings. I have the following problem was finishing validating the following code and and it works well if I place a whole number works but it does not work well as this is the image I think it is a problem of the meter because if I omit it works but I need it for auto increase the row number that is reading from the file ...... if I put 5 instead of i it works since that is the line that was valid NADBY. I mean the problem is not that line is the data you receive ... additionally try by console line by line and verify and according to console everything is fine
class EncoderController < ApplicationController
@encoderr = File.foreach('ojos.txt').with_object([]) do |line, result|
if line.start_with?('NADBY')
clave = line[0..4]
region = line[6]
proveedor = line[7...-2]
cajas = line[-2..-1]
result << "#{clave} región #{region}, #{proveedor}, tipo de cajas #{cajas}"
end
end
end
vista ------->>>>> <h1> <%= @encoderr %> </h1> <<------------vista