<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Action Controller: Exception caught.]]></title>
		<link>http://railsforum.com/viewtopic.php?id=1135</link>
		<description><![CDATA[The most recent posts in Action Controller: Exception caught..]]></description>
		<lastBuildDate>Thu, 09 Nov 2006 08:30:27 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Action Controller: Exception caught.]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=5682#p5682</link>
			<description><![CDATA[<p><img src="http://railsforum.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /> bingo. thanks again ryanb</p>]]></description>
			<author><![CDATA[dummy@example.com (BasicMind)]]></author>
			<pubDate>Thu, 09 Nov 2006 08:30:27 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=5682#p5682</guid>
		</item>
		<item>
			<title><![CDATA[Re: Action Controller: Exception caught.]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=5647#p5647</link>
			<description><![CDATA[<p>I don&#039;t think the problem has anything to do with displaying the errors. The problem is happening when attempting to loop through the @userlist array after the form is submitted with an error in it. This is because that view is rendered, but the @userlist variable is not created in the add_a_user action. You need to create the @userlist there as well:</p><p><pre name="code" class="ruby:nogutter">#...<br />else<br />&nbsp; @userlist = User.account_users(@account.id)<br />&nbsp; render_action &#039;list_users&#039;<br />end</pre><br />This leaves duplicate code, so I recommend moving it into a before filter or something.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Wed, 08 Nov 2006 22:24:06 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=5647#p5647</guid>
		</item>
		<item>
			<title><![CDATA[Action Controller: Exception caught.]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=5642#p5642</link>
			<description><![CDATA[<p>okay I keep getting this error when I run this method.</p><p>[code error]You have a nil object when you didn&#039;t expect it!<br />You might have expected an instance of Array.<br />The error occured while evaluating nil.each[/code]<br />okay it is a list of users with a form at the bottom to allow you to add a new user. the whole thing works fine. untill an error is thown by the a field not being entered. If I dont add the <pre name="code" class="ruby:nogutter">&lt;%= error_messages_for &#039;user&#039; %&gt;</pre><br />its all fine. but I dont get the error messages.</p><p>okay these are the methods that are being used.<br />[code methods]def add_a_user<br />&nbsp; &nbsp; @user = User.new(params[:user])<br />&nbsp; &nbsp; @user.account_id = @account.id<br />&nbsp; &nbsp; if @user.save<br />&nbsp; &nbsp; &nbsp; flash[:notice] = &quot;#{@user.username} Added&quot;<br />&nbsp; &nbsp; &nbsp; redirect_to :action =&gt; &quot;list_users&quot;<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; render_action &#039;list_users&#039;<br />&nbsp; &nbsp; end</p><p>&nbsp; def list_users<br />&nbsp; &nbsp; @userlist = User.account_users(@account.id)<br />&nbsp; end[/code]<br />and the views<br />[code list_users view]<br />&lt;table width=&quot;700&quot;&gt;<br />&nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;UserName:&lt;/td&gt;&lt;td&gt;Email Address:&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &lt;/tr&gt;<br />&lt;% for list in @userlist -%&gt;<br />&nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= list.username %&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= list.email_address %&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= link_to &quot;Delete&quot;, {:action =&gt; &quot;delete_user&quot;, :id =&gt; list.id},<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; :confirm =&gt; &quot;Are you sure you want to delete #{userlist.username}&quot;%&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= link_to(&quot;Suspend&quot;, :action =&gt; &quot;suspend_user&quot;)%&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= link_to(&quot;Edit&quot;, :action =&gt; &quot;edit_user&quot; )%&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &lt;/tr&gt;</p><p>&lt;% end -%&gt;</p><p>&lt;/table&gt;<br />&lt;hr&gt;<br />&lt;%= render_partial &quot;add_a_user&quot; %&gt;<br />[/code]</p><p>[code and the partaial]<br />%= error_messages_for &#039;user&#039; %&gt;</p><p>&lt;%= start_form_tag(:action =&gt; &quot;add_a_user&quot;) %&gt;</p><p>&lt;table&gt;<br />&nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td colspan=&quot;4&quot;&gt;Add a User&lt;/td&gt;<br />&nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;UserName&lt;/td&gt;&lt;td&gt;Email Address&lt;/td&gt;&lt;td&gt;Authority&lt;/td&gt;&lt;td&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= text_field(&quot;user&quot;, &quot;username&quot;, &quot;size&quot; =&gt; 20)%&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= text_field(&quot;user&quot;, &quot;email_address&quot;, &quot;size&quot; =&gt; 20)%&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;i&gt;member&lt;/i&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;%= submit_tag(&quot; ADD USER &quot;)%&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;%= end_form_tag %&gt;<br />[/code]</p><p>although it works without the error messages, I would like them there <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (BasicMind)]]></author>
			<pubDate>Wed, 08 Nov 2006 21:58:19 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=5642#p5642</guid>
		</item>
	</channel>
</rss>
