Ruby on Rails - Import CSV file -


I am following this tutorial but doing something wrong because I get a silly error when I make my own I'm trying to object Undefined Continuous Quanta Contents Controller :: False I can read the file without problems, but this error is giving me a headache! Any help would be appreciated!

The method of importing into my controller (cuenta_contable_controller.rb) looks like this;

  Class quantacontributions controller & lt; ApplicationController .... DRF Upload (Parameters) logger.info "** File Loaded ***" infile = params [: file] .read n, errs = 0, [] @archivo = [] SV.prese ( Infilay). Line | N + = 1 # SKIP: Header i.e. The first row or empty line next if n == 1 or row.join.blank? Cuenta_contable = CuentaContable.build_from_csv (line) if cuenta_contable.valid? Cuenta_contable.save @archivo & lt; & Lt; Row and forgets & lt; & Lt; End of line end logger.info flash [: success] = "Las Quant's Contrables Fireon Corps." Response_to do | Format | Format.html # index.html.erb format.json {Render: json = & gt; @ Archivo} and end   

and my model (cuenta_contable.rb) like this

  class quanta contextable & lt; ActiveRecord :: Base .... def self.build_from_csv (line) ultimo_nivel = (line [5] .downdown == "C")? (True): (false) #cuenta = find_or_initialize_by_cuenta ("# {line {0}} - # {line {1}} - # {line {2}}" # Create an e-mail or new quanta for the existing customer = CuentaContable.new (cuenta = & gt; "# {line [0]} - # {line {1}} - # {line {2}}" ,: descripcion => "# {line [3] .titleize } ",: Categoria_cuenta = & gt;" # {line [4] .titleize} ",: ultimo_nivel => ultimo_nivel) return cuenta end    

You are using true instead of true (similar to false ).

But neither is necessary; Not too bad and more-bracketed:

  #Ick! Ultimo_nivel = (line [5]. Downcas == "C")? (True): (false) #Good! Ultimo_nivel = Row [5]. Downcase == "C"   

You may use an assistant to turn on line 5 in the boolean and delete it from the mainline code. < / Div>

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -