So I'm not exactly using Rails, but just ActiveRecord. Though I felt
this would be more appropriate in the Rails forum than the general Ruby
forum.

I'm working on an app that interacts with databases, without having a
database of its own.

I have a class called Modeller, and a Modeller#retrieve_model(name)
method that takes a name, looks for a table matching that name, creates
a model that inherits from ActiveRecord::Base and returns it. It works
great.

So I can enter:

m     = Modeller.new(<params for connecting to db>)
model = m.retrieve_model('page')

And I get back a model called Page, connected to the database and ready
to go.

But a problem occurs when I try to call methods on it with
BasicObject#send.

I take a list of fields from a yaml file (user supplied) then attempt to
update the fields with BasicObject#send.

yaml file example -
  content:        some content
  parent_id:      1
  children_count: 0
etc.

So my code ends up like this:

model.send('content', 'some content')

And it blows up with an error:

ArgumentError: wrong number of arguments (1 for 0)
    
/home/zatz/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activerecord-4.0.1
/lib/active_record/attribute_methods/read.rb:58:in
`__temp__37964756f59646'
    
/home/zatz/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activerecord-4.0.1
/lib/active_record/attribute_methods.rb:150:in `method_missing'

And I'm stumped. What's going on?

A very big thank you ahead of time to whoever can help me figure this
out. I'm totally open to an alternative way of doing this too.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d01ec95f4915d032f1c85570223a1bd6%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to