Im new on the ruby on rails How can i read datas from csv files? I have a csv file, and it has datas like name surname etc.
Here, there is a name surname variables. I need to read from csv files. How can i do it?
my codes now like this:
require 'csv'
table = CSV.parse(File.read("csv files/department.csv"), headers: true)
class Person
@name
@surname
@role
@department
def printPersonFullname(name, surname)
@name = name
@surname = surname
puts ("#{@name} #{@surname}")
end
end
here csv file image:
By the way, when i print, console print this:
D:\Ruby27-x64\bin\ruby.exe: No such file or directory -- csv.rb (LoadError)
