<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It complains about a missing param to assign_attributes: <a href="http://api.rubyonrails.org/" class="">http://api.rubyonrails.org/</a><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 8 Mar 2017, at 14:10, Jesse Waites <<a href="mailto:jesse.waites@gmail.com" class="">jesse.waites@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi all--<div class=""><br class=""></div><div class="">I have been tasked with building a report card feature. The end goal of this is that the user gets a monthly email with various statistics (Users logged in, Sites activated, things like hat)</div><div class=""><br class=""></div><div class="">I have settled on Report Stat model and Report Card models. One a month, Report Stat will run and save that data. I take the last 2 report stats (or any 2 report stats, really - thats why I built it this way) and generate the Report Card.</div><div class=""><br class=""></div><div class="">The thing is, most of the data from the Report Card will be the same data from the most recent Report Stat. The users_logged_in from the most recent Report Stat scan will be the number of users_logged_in in the Report Card. There are a few instances where I will want a percentage increase or decrease between Report Stats, I have a integer column ready for that and will just perform simple math on :users_logged_in between my various time frames via various Report Stats.</div><div class=""><br class=""></div><div class="">My issue is, how can I most easily transplant the data from ReportStat into the ReportCard. I could so it manually column by column but that seems like the wrong way to do it, I want to do it programmatically. The columns and datatypes are all the same.</div><div class=""><br class=""></div><div class="">At the end of the day, I think I'd like to be able to do ReportCard.create(:user_id => <a href="http://current_user.id/" class="">current_user.id</a>, 6, 7)</div><div class=""><br class=""></div><div class="">with 6 and 7 being the ID number of the reports I want comparisons from.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I am trying it this way but am getting "wrong number of arguments:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">class ReportCard < ActiveRecord::Base</div><div class="">  belongs_to :user</div><div class=""><br class=""></div><div class="">  attr_accessible :user_id, :oldest_report_stat_id, :newest_report_stat_id, :num_active_and_licensed_aeds,</div><div class="">  :num_active_sites, :num_users_logged_in, :aeds_total, :aeds_compliant, :aed_sites_total,</div><div class="">  :aed_sites_compliant, :responders_total, :responders_compliant, :num_active_and_licensed_aeds_percentage,</div><div class="">  :num_active_sites_percentage, :num_users_logged_in_percentage, :aeds_compliant_percentage,</div><div class="">  :aed_site_compliant_percentage, :responders_compliant_percentage, :report_start_time, :report_end_time</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">  def execute</div><div class="">    @newest_stat = ReportStat.find(self.newest_report_stat_id)</div><div class="">    @oldest_stat = ReportStat.find(self.oldest_report_stat_id)</div><div class="">    #@newest_stat.inspect</div><div class="">    @newest_stat.assign_attributes.each do |attr_name, attr_value|</div><div class="">      self.send("#{attr_name}=", "#{attr_value}")</div><div class="">    end</div><div class="">    # calculate_percentage_change</div><div class="">  end</div><div class=""><br class=""></div><div class="">end</div><div class=""><br class=""></div><div class="">Here is my rails console output:</div><div class=""><br class=""></div><div class=""><pre style="" class="">r = ReportCard.new
=> #<ReportCard id: nil, user_id: nil, created_at: nil, updated_at: nil, oldest_report_stat_id: nil, newest_report_stat_id: nil, num_active_and_licensed_aeds: nil, num_active_sites: nil, num_users_logged_in: nil, aeds_total: nil, aeds_compliant: nil, aed_sites_total: nil, aed_sites_compliant: nil, responders_total: nil, responders_compliant: nil, num_active_and_licensed_aeds_percentage: nil, num_active_sites_percentage: nil, num_users_logged_in_percentage: nil, aeds_compliant_percentage: nil, aed_site_compliant_percentage: nil, responders_compliant_percentage: nil, report_start_time: nil, report_end_time: nil>
[2] pry(main)> r.oldest_report_stat_id = 6
=> 6
[3] pry(main)> r.newest_report_stat_id = 7
=> 7
[4] pry(main)> r.execute
  ReportStat Load (1.3ms)  SELECT "report_stats".* FROM "report_stats" WHERE "report_stats"."id" = $1 LIMIT 1  [["id", 7]]
  ReportStat Load (0.4ms)  SELECT "report_stats".* FROM "report_stats" WHERE "report_stats"."id" = $1 LIMIT 1  [["id", 6]]
ArgumentError: wrong number of arguments (0 for 1..2)
from /Users/enpro/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-3.2.17/lib/active_record/attribute_assignment.rb:66:in `assign_attributes'</pre></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Any ideas? Maybe syntax error? Ive dumped way too much time into this and need to move on to the rest of the feature. Thank you LRUG!</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Jesse Waites</div><div class="">Web Developer</div><div class=""><a href="http://jessewaites.com/" target="_blank" class="">JesseWaites.com</a></div></div></div></div></div></div></div></div>
</div></div>
_______________________________________________<br class="">Chat mailing list<br class=""><a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">Archives: http://lists.lrug.org/pipermail/chat-lrug.org<br class="">Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org<br class="">List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org<br class=""></div></blockquote></div><br class=""></div></body></html>