Update ActiveRecord with a send

I am iterating through a hash, and if the hash key matches the column name (as defined by attr_accessible), then I want to update that column.

def self.load_primer3_output(rawfile_hash)
  primer3_output = Primer3Output.new
  rawfile_hash.each do |key, value|
    if primer3_output.class.accessible_attributes.include?(key)
      primer3_output.send(key) = value

I am getting a syntax error on the send:

** [out ::]     /home/assay/apps/assay/releases/20130823054701/app/workers/primer3_query.rb:96: syntax error, unexpected '=', expecting keyword_end
** [out ::] (
** [out ::] SyntaxError
** [out ::] )
** [out ::]
** [out ::] primer3_output.send(key) = value
** [out ::]
** [out ::] ^


eval works, by the way. I would prefer to use send though.

if primer3_output.class.accessible_attributes.include?(key)
    #primer3_output.send(key) = value
    eval("primer3_output.#{key} = value")


Change it to

primer3_output.send("#{key}=", value)

when using send method the key should be symbol and string.

change to this when using symbol.

primer3_output.send(key.to_sym) = value

change to this when using string.

primer3_output.send("#{key}=", value)

Need Your Help

jquery table sorting and css fix for IE 8

jquery css internet-explorer table sorting

I'm attempting to make this page compatible with IE 8. The jquery right now allows for classes to be assigned on odds and evens, but doesn't seem to be working on IE 8.

Is there any way to identify a person's title through NLTK?

python algorithm machine-learning nltk

I'd like to be able to extract the title or job position of a person from a short description.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.