Title / Description
Code def self.insert_samples str re = /(?<=\[@)(\d+)(?=\])/ samples = Hash.new self.find(str.scan(re).map { |a| a.join }).map do |obj| samples[obj.id.to_s] = obj end while num = str[re] str.sub!("[@#{num}]", samples[num].script) end str rescue ActiveRecord::RecordNotFound => e Rails.logger.error e.to_s return nil end
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code