[rspec-users] RSpecers point of view about how to create rails association
lists at ruby-forum.com
Sat May 2 12:00:56 EDT 2009
Using Ruby on Rails, let's says I have an Article model and Comment
model. An Article has_many :comments,
Using Rais idiom, one would do something like that in the
@article = Article.find(params[:id])
I don't like too much this approach because it puts too much
intelligence into the controller and it's not easy to test/spec/mock.
So I'd like to push this into a model. So would you tell Article model
to create a new Comment given params[:comment], or would you tell
Comment to create a new Comment given an article_id?
>From a BDD point of view, only creating a new comment record is what
counts, but I'd like to be more careful about Demeter, encapsulation,
tell don't ask, ...
Posted via http://www.ruby-forum.com/.
More information about the rspec-users