Im stuck with my current task, partly because there seems to be a lack
of basic understanding of syntax i cant pinpoint. I hope you can show me
a way out!
What Im trying to do is processing one model's data, thus turning it
into another model's data. It works with one datum, but I cant get it to
work with the whole data set. I tried several versions of code in
several places, but this is the current version:
class RawDatum < ActiveRecord::Base
default_scope :order => 'raw_data.timestamp DESC'
i = 0
RawDatum.find_each do |raw|
data[i] = ProcessedDatum.create
data[i].period_label = raw.status
i += 1
class ProcessedDatum < ActiveRecord::Base
class ProcessedDataController < ApplicationController
@data = RawDatum.process_raw_data
when i open localhost:3000/processed_data/, i get the following error:
undefined local variable or method `data' for #<Class:0x9c785f4>
app/models/raw_datum.rb:11:in `block in process_raw_data'
the data variable is supposed to be an array that should hold
ProcessedDatum-objects, its just a container variable. it seems i have
to define it, but how would I do that? am i doing this entirely wrong,
and if so, what would be a better way?