0

I have a form that is used to generate a report. In this form I have a number of flags set - that will then dictate what my report does.

These variables are then passed to the model and I pick them up

attr_accessor :make_charge

At this point I know I have the variable as I can log it.

I then pass off to the generatereport file.

This file picks up

attr_accessor :member
attr_reader :make_charge

The report is generated - and the various properties the member has are ok, but I cannot access the value of make charge.

How how do I set a value in one file and then access in another? It would seem to me the attr_accessor and attr_reader do this - but I seem to be doing it wrong. (Which we have all agreed on)

The report is generated just fine - what I want to do is a new action on the records of this report - based on a setting in the original form submission. I was hoping to do it in one process - to set the parameters - have the report run and then the records adjusted. The flag is not part of the model. it's a flag if set do something once report is complete.

The report generator is

MemberAccountsByStatusAndDateReportGenerator.new(
Member.
includes(:balances).
joins(:balances).
where{with_balances}. 
where(status: report_options[:status]).
where{last_login_at >= start_date }.

where{last_login_at <= end_date}  
).to_csv_file(file_name, linesep: "\r\n", colsep: ",")

once the report is run I want to be able to do something to the records based on a different report_option [:variable] But I need to get that variable to the action that creates the file.

techguy
  • 47
  • 2
  • 9
  • huh? `attr_accessor` and `attr_reader` only do anything within a class context (see [this question](http://stackoverflow.com/questions/4370960/what-is-attr-accessor-in-ruby)), but you seems to be discussing them here as if they are reading/setting global variables. Unless I am misunderstanding what you're doing this just Will Not Work. – acobster Jan 08 '16 at 19:18
  • @acobster We are certainly agreed that my understanding was wrong - and that my approach Does Not Work. The question then becomes How how do I set a value in one file and then access in another (which is a different class) – techguy Jan 08 '16 at 19:29
  • Can you show your form code and `generatereport` call? – Inpego Jan 08 '16 at 19:35
  • Thanks for clarifying. :) There's not really enough code here to get a sense of the architecture of your application. Please post the code in more detail. I am assuming your form submission triggers a specific controller action? If that's the case why are you worried about "files" at all? In the Rails world you should really be thinking more about actions and the Models (classes) they act upon. – acobster Jan 08 '16 at 19:35

0 Answers0