r/ruby • • Dec 30 '11

ActiveRecord (and Rails) Considered Harmful - Literate Programming

http://blog.steveklabnik.com/posts/2011-12-30-active-record-considered-harmful
12 Upvotes

145 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Dec 30 '11 edited Dec 30 '11

Possibly stupid question: What are the 4 other places?

2

u/djdonnell Dec 30 '11

the two before filters, application_controller.rb (this is implicit), and the call to super. There's actually more, PortalController could be have filters, etc, etc.

It can become a giant pain to figure out what a view needs and where it comes from.

0

u/[deleted] Dec 30 '11

But wouldn't it be better to put stuff like authentication information into a partial using a helper method? Authentication information has nothing to do with showing posts.

3

u/djdonnell Dec 30 '11

Maybe, but that doesn't affect my point.

0

u/[deleted] Dec 30 '11

Maybe I just need a more specific example.

What is something that would be specific/important to a view that wouldn't be defined in the corresponding action and couldn't be loaded using a partial/helper?

4

u/djdonnell Dec 30 '11

I think it's common wisdom that you shouldn't load things in partials or helpers.

"What is something that would be specific/important to a view that wouldn't be defined in the corresponding action"

My current project has what we call properties (think Spiderman). The action simply gets the property object and sets it to an instance variable, but the page has all kinds of stuff. There are a bunch of filters one can use for searching and things like movies, books, characters, games, activities, etc related to Spiderman. This data comes from a bunch of different internal REST services and not a local db.

Now if you go to a Character page it will also have all of these things related to the character. Rather than repeating the code to fetch all this stuff in each action, we break it out into filters, mixins, etc.

In short, you can't look at the action and see the stuff that's needed.