It’s way past midnight and I’m about to go to sleep. I’m having
doubts about my code now that I’m trying to test as I go.
Now my model follows the pattern of the LineItem model in the rails
Basically the User has one Group and this one Group has many Friends
(polymorphic two-way as “befriender” and “befriended”–users).
from Friend.rb (here the “befriender” and “befriended” that are passed
into the model are User objects)
def self.befriend_user(befriender, befriended)
friend = self.new
friend.befriender = befriender
friend.befriended = befriended
befriender.group.friends << friend
Should I be breaking this up into smaller methods? Is there a better
way to do it? Is my design brittle or convoluted?
How would I write a Unit Test for the above?
Really stupid questions: why do I need the “friend” right before the
I know these are a lot of questions but I really can’t find any good
information out there about good design patterns for an integrated
rails MVC/TDD approach so a few pointers would be appreciated.