Tuesday, 10 September 2013

ActiveRecord Associations in Sinatra WITHOUT Rails

ActiveRecord Associations in Sinatra WITHOUT Rails

I'm trying to modify a simple, Sinatra-based blog app from here:
http://www.danneu.com/posts/15-a-simple-blog-with-sinatra-and-active-record-some-useful-tools/
I want it to include Rails-ish, ActiveRecord "has_one" language in the
Post class...
class Post < ActiveRecord::Base
has_one :blogger
end
associating it a "blogger" connected to a 2nd class Blogger:
class Blogger < ActiveRecord::Base
end
In my database schema, I've created a "blogger_id" column in my Posts
table, but it doesn't seem to let me set it using a "blogger=" method or
anything.
Does anyone know how to implement this kind of association?
The goal here is to use the ActiveRecord Association macros in Sinatra...

No comments:

Post a Comment