Skip to main content
8 events
when toggle format what by license comment
Feb 11, 2016 at 13:16 vote accept Daniel
Feb 10, 2016 at 6:17 comment added 200_success Your original code had attr_accessor rather than attr_reader, so I assumed that you wanted those attributes to be writable, which means that when defining the attribute reader, you need to check the instance variable.
Feb 10, 2016 at 6:07 comment added Daniel Sorry, there's something I don't understand. What is the point of the if instance_variable_defined?("@#{name}"); instance_variable_get("@#{name}")? With your solution, the attributes become methods instead of instance variables.
Feb 10, 2016 at 5:52 comment added 200_success That seems reasonable. In fact, if you have the module extend ActiveSupport::Concern, then you can write it slightly more gracefully, as in the docs.
Feb 10, 2016 at 5:51 comment added Daniel Also, yes, the model is transient. Its function is just to provide data of several reports to a controller.
Feb 10, 2016 at 5:39 comment added Daniel This refactoring looks great! I learned many things. Thanks! Out of curiosity, would you put the ParamAccessors module in the Concerns directory?
Feb 10, 2016 at 5:15 history edited 200_success CC BY-SA 3.0
added 144 characters in body
Feb 10, 2016 at 5:05 history answered 200_success CC BY-SA 3.0