<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'delete_user in login_controller' | Pragmatic Forums</title>
    <link>https://forums.pragprog.com/forums/22/topics/356</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>delete_user in login_controller posted by Mark Adkins @ Sat, 05 Apr 2008 21:10:05 -0000</title>
      <description>&lt;p&gt;Ack, sorry. Didn&amp;#8217;t mean to hit submit.&lt;/p&gt;


	&lt;p&gt;This is the code for delete_user:&lt;/p&gt;


&lt;code&gt;
def delete_user
    if request.post?
      user = User.find(params[:id])
      begin
        user.destroy
        flash[:notice] = "User #{user.name} deleted." 
      rescue Exception =&amp;gt; e
        flash[:notice] = e.message
      end
    end
    redirect_to(:action =&amp;gt; :list_users)
  end
&lt;/code&gt;

	&lt;p&gt;The problem line, apparently, is 46: user = User.find(params[:id])&lt;/p&gt;


	&lt;p&gt;But, I don&amp;#8217;t know why it&amp;#8217;s wrong. Any thoughts?&lt;/p&gt;</description>
      <pubDate>Sat, 05 Apr 2008 21:10:05 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:22:356:2550</guid>
      <author>Mark Adkins</author>
      <link>https://forums.pragprog.com/forums/22/topics/356</link>
    </item>
    <item>
      <title>delete_user in login_controller posted by Mark Adkins @ Sat, 05 Apr 2008 21:08:17 -0000</title>
      <description>&lt;p&gt;I&amp;#8217;ve copied the delete_user action directly from the book. It&amp;#8217;s exactly the same. However, instead of deleting a user, I get this error:&lt;/p&gt;


&lt;pre&gt;
ActiveRecord::RecordNotFound in LoginController#delete_user

Couldn't find User with ID=user

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1031:in `find_one'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1014:in `find_from_ids'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:419:in `find'
#{RAILS_ROOT}/app/controllers/login_controller.rb:46:in `delete_user'
&lt;/pre&gt;</description>
      <pubDate>Sat, 05 Apr 2008 21:08:17 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:22:356:2549</guid>
      <author>Mark Adkins</author>
      <link>https://forums.pragprog.com/forums/22/topics/356</link>
    </item>
  </channel>
</rss>
