简体   繁体   中英

How to search Ruby/Rails' syntax

As a beginner, I always have problems about some method when coding. For example, when I'm writing a import csv feature, I don't know whether a new could take a block as a variable, and what the CSV.foreach iterates through.

def self.import(file, date)
  CSV.foreach(file.path, header: true) do |row|
    point = Point.find_or_create_by_name(row["name"])
    point.observations.new do |observation|
      observation.value =  row["value"]
      observation.record_date = date
    end
  end
end

For most developers, these are easy questions, but for beginners like me, these are real-life problems that we really struggle about.

How do we search for Ruby's syntax?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM