I have started learing ruby by myself couple of weeks ago and now I'm trying to do some small app.
I have been searching for the solution of this problem buy I couldn't find it.
In my models I have a class called TimeRecord.
In my views I have time_records/upload.erb.html. Here is where I have a form to upload an Excel file.
What I need is to read that Excel file and insert all the objects in the database.
Then I have this in the controller:
class TimeRecordsController < ApplicationController def upload if (params[:uploaded_file].present?) book = Spreadsheet.open params[:uploaded_file].tempfile sheet1 = book.worksheet 0 sheet1.each 1 do |row| @time_record = TimeRecord.create(:employee_id => 1 , :datetime => DateTime.parse(row)) @time_record.save end end end end
And when I want to try it I get this error (and the @time_record assignment is highlighted):
ActiveRecord::DangerousAttributeError in TimeRecordsController#upload hash is defined by Active Record
Any ideas what I am doing wrong? Thanks so much for your help!
PS: Im using Ruby 2 and Rails 4