Hi,

Thank you for your reply. I only have one admin on the website as shown
below (code taken from seeds.rb).

User.create(:name => "weds4u", :password => "w", :password_confirmation
=> "w", :role => 'admin')
User.create(:name => "Afsheen",  :password => "a",
:password_confirmation => "a", :role => '')

I tried the following IF statement from another website but that doesn't
seem to work. Could you suggest some correction to the below code or do
I need to change where I am putting the code in the first place?


def destroy
    @user = User.find(params[:id])
  if not user.role = 'admin'
    @user.destroy
else
    respond_to do |format|
        format.html { redirect_to users_path,
                notice: "#{@user.name} is an admin. You do not have
permission to delete this user" }
      format.json { head :no_content }
    end
  end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/10e7e5bfcb5496400ee95fc1364b50a6%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to