On Tue, Jun 16, 2009 at 5:12 PM, Fernando Perez
<[email protected]> wrote:
> In my views I often find myself doing:
>
> <%= user.login %>
>
> These get scattered all over the application. Now imagine I change the
> user's login to name. What happens? It blows in my face. Sure tests can
> catch it, but writing tests for that purpose is too painful.
>
> So what kind of tips / ideas / idioms / Design Patterns / other? do you
> use to truly decouple the View from the Model.
>
> One should never access object's attributes like this in the view, and
> yet we see this in almost all tutorials, books and what have you. It's
> now hard for me to get rid of that bad habit, and I don't even know how.

#!/bin/sh
cd app/views
for file in */*erb; do
  cp $file $file.tmp
  sed -e "s/user\.login/user\.name/g" $file.tmp >$file
  rm $file.tmp
done


--
Greg Donald
http://destiney.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to