<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Also, I can't think of many situations in which one sets an instance variable in a Rails controller (with the exception of setting up an object in a before_filter for use in an action - see conversations passim) for any reason other than exposing it to the view. I'm not convinced that changing "@post = foo" to some explicit means of passing the data to the view is a huge inconvenience.<div><br></div><div>But I may have forgotten myriad use cases for instance variables in Rails controllers, in which case please forgive and ignore this post.</div><div><br></div><div>Cheers,</div><div><br></div><div>Tom</div><div><br><div><div>On 2 Apr 2012, at 16:05, James Hunt wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">How much more convenient is it though? How much time do you really save by having instance variables by default? It's interesting to think about this the other way: if Rails had never exposed instance variables by default, would you even miss it? Would you have written a gem to add the functionality? How would you justify it?<div>

<div><br></div><div>In the scheme of all the things you have to do to get a Rails app working, not having instance variables in views seems like a really small thing. And if you were reaaaaallly desperate, you could do:</div>

<div><br></div><div><% @post = post %></div><div><br></div><div>at the top of your view and you're back in business! The only difference here is that before you do something like the above, you have to actually think about what you're doing and why before you do it. It's a convention: break it if you want, but know why you're doing it and what it may cost you later on.</div>

<div><br></div><div>James</div><div><br><div class="gmail_quote">On Mon, Apr 2, 2012 at 2:43 PM, Ed James (Alt) <span dir="ltr"><<a href="mailto:ed.james.spam@gmail.com">ed.james.spam@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div>
                    Further to Andy's comment, we also need to remember that many Rails apps start off as prototypes. The prototypes that work quite often make it to a version release, which doesn't always allow for much refactoring. Stuff has to get done quickly and this is what makes Andy's "instant access" valuable. It can also be quite cumbersome to have too many strict rules (and even tests!) when the requirements are in a constant state of flux, which is common in early development stages.
                </div><span class="HOEnZb"><font color="#888888">
                <div><div><br></div><div>-- </div><div>Ed James</div><div>Sent with <a href="http://www.sparrowmailapp.com/?sig" target="_blank">Sparrow</a></div><div><br></div></div></font></span><div class="HOEnZb"><div class="h5"><p style="color:#a0a0a8">On Monday, 2 April 2012 at 11:42, Andrew Stewart wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
                    <span><div><div><div><br></div><div>On 2 Apr 2012, at 12:20, Viktor Tron wrote:</div><blockquote type="cite"><div>I don't know who came up with this pattern in rails in the first place, it violates everything you ever wanted objects and instance variables to mean.</div>

</blockquote><div><br></div><div>True, but you have to admit it's tremendously convenient ;)</div><div><br></div><div>I know it's heretical to say so but I like being able to access instance variables as if by magic in my views.  I came to Rails from J2EE / JSP / servlets where accessing controller data in views was outstandingly tedious.  I know Rails' approach violates encapsulation and so on...but I like it.</div>

<div><br></div><div>Cheers,</div><div><br></div><div>Andy Stewart</div><div>----</div><div><a href="http://airbladesoftware.com/" target="_blank">http://airbladesoftware.com</a></div><div>_______________________________________________</div>

<div>Chat mailing list</div><div><a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a></div><div><a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a></div>

</div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>
            </div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br></div></div>
_______________________________________________<br>Chat mailing list<br><a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>http://lists.lrug.org/listinfo.cgi/chat-lrug.org<br></blockquote></div><br></div></body></html>