RailsCasts Pro episodes are now free!

Learn more or hide this

Maxim Chernyak aka hakunin's Profile

GitHub User: maxim

Site: http://github.com/maxim

Comments by Maxim Chernyak aka hakunin

Avatar

Ryan, it looks like in the second half of the episode you were really after ActiveRecord's to_partial_path, which you can define in Activity model and have it perform all of your path-building logic. It becomes a clear winner when you notice that

"activities/#{activity.trackable_type.underscore}/#{activity.action}"

becomes

"activities/#{trackable_type.underscore}/#{action}"

Makes more sense to have it come from inside the activity object itself. In the view you could then simply call render activity, and it would automatically call to_partial_path on the model. When this logic is moved into model like that, presenter is left somewhat empty, and in this specific case becomes excessive.

Avatar

It's not bad, but you won't be able to modify variables, and extend css rules with other css rules. (The latter of which I was hoping Ryan would cover, but topic is too wide, and this cast is great still). Basically, with plain files you can't use any dynamic power of sass or less to modify things in bootstrap itself, only override the plain css.

Avatar

The video is slightly cut-off at the end. Also the backbone-on-rails link in the show notes is pointing to another lib on github.

P.S. Great job as usual. Was meaning to play with backbone.