title: How to loop over model attributes and use them as symbols else where
body: <p>I'm trying to loop over a the attr_accessor-able variables in an <code>ActiveModel::Model</code> and then fetch corresponding records from the db based on them, the problem is that it's not finding the record.</p>
  
  <pre><code>class DeployOptionForm
    include ActiveModel::Model
    attr_accessor :revision_number
  end
  </code></pre>
  
  <p>And this is the code I was trying to get them.</p>
  
  <pre><code>dof.instance_variables.each do |var_sym|
    dof_var = dof.instance_variable_get(var_sym)
    var_sym.to_s.slice!(0).to_sym
    doe = DeployOption.new
    doe.value = dof_var
    doe.deploy_option_type = DeployOptionType.find_by name: var_sym
    doe.deploy = @deploy
    doe.save
  end
  </code></pre>
  
  <p>I know that if I do<br>
  <code>doe.deploy_option_type = DeployOptionType.find_by name: :revision_number</code><br>
  the record is found just fine but I'm trying to make it more adaptable.</p>
  
  <p>So what do I need to do to <code>var_sym</code> to be able to do <code>DeployOptionType.find_by name: var_sym</code> ?</p>