RailsCasts Pro episodes are now free!

Learn more or hide this

Steve Klabnik's Profile

GitHub User: steveklabnik

Site: http://steveklabnik.com/

Comments by Steve Klabnik

Avatar

view_context is a method on ActionController::Metal (iirc) that builds a new 'view context object.' This is usually an instance of ActionView::Base, but is override-able. Every time you call it, it generates a new one, because caching is hard, basically.

Avatar

Hi there! I maintain both AMS and Draper, so maybe I can give you some insight. ;)

Draper is about general decoration, AMS is about serializing to JSON. I know several people that use both together: Draper for adding presentation-only concerns, and then AMS to actually do the conversion.

It's arguable that serialization and view-specific logic are two different concerns, and require two different objects.

Also, if you use Draper's #to_json, you miss out on the conventions that AMS provides.

Avatar

Rails is built on conventions. AMS is built on conventions. RABL and JBuilder are built on customizing every last detail of the response.

Avatar

I literally just merged respond_to support yesterday, so it wasn't there when he reviewed.

Also, respond_to isn't all that great, many of us don't actually use it.

Avatar

Yes, I'd agree with this. For unit-style tests, one assertion per test makes sense, but for integration or acceptance tests, multiple assertions are perfectly okay.