<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - ruby has class scope not method scope, correct?]]></title>
		<link>http://railsforum.com/viewtopic.php?id=43592</link>
		<description><![CDATA[The most recent posts in ruby has class scope not method scope, correct?.]]></description>
		<lastBuildDate>Wed, 06 Apr 2011 19:28:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[ruby has class scope not method scope, correct?]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=139405#p139405</link>
			<description><![CDATA[<p>Hey all,</p><p>ruby has class scope not method scope, correct?</p><p>So in this class, for example:</p><p>class RestfulController<br />def extract_resource_model<br />&nbsp; &nbsp; resource_model_name<br />&nbsp; &nbsp; resource_model<br />&nbsp; end<br />&nbsp; <br />&nbsp; def resource_model_name<br />&nbsp; &nbsp; #@resource_model_name ||= self.class.resource_model_name || controller_name.singularize<br />&nbsp; &nbsp; @resource_model_name ||= controller_name.singularize<br />&nbsp; &nbsp; <br />&nbsp; end<br />&nbsp; <br />&nbsp; def resource_model<br />&nbsp; &nbsp; @resource_model ||= Kernel.const_get(@resource_model_name.camelize)<br />&nbsp; end<br />&nbsp; <br />end</p><p>when resource_model_name is called, resource_model_name returns an instance variable @resource_model_name as part of the return value in extract_resource_model method. Now that instance variable @resource_model_name is available throughout all the instance methods in that class, correct?&nbsp; That&#039;s why I am able to access it without any problems with scope resolution in resource_model, correct?</p><p>Thanks for response.</p>]]></description>
			<author><![CDATA[dummy@example.com (johnmerlino)]]></author>
			<pubDate>Wed, 06 Apr 2011 19:28:48 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=139405#p139405</guid>
		</item>
	</channel>
</rss>
