The following import method needs to handle input variables set as nil
def self.import(file, unit_id, profit_center_column [...]
CSV.foreach(file.path, :col_sep => "\t", headers: true, skip_blanks: true) do |row|
begin
Asset.create(
unit_id: unit_id,
profit_center_id: row[profit_center_column] unless profit_center_column.nil?,
[...]
Where the controller launching this method defines
params[:profit_center_column] = @unit.profit_center_column
where @unit.profit_center_column = nil.
I am hitting an unexpected syntax error, unexpected modifier_unless, expecting ')' I have never had to use parenthesis before using unless and I woudl expect the use of the comma here to clearly seperate the statements. Where is the syntax getting messed up?
Rails 4.2.4 and Ruby 2.3.4 are in use.
Note, I've also attempted if statements, but that led to loading random xxx_column information.