Я пытаюсь удалить с помощью действия удаления.Но всякий раз, когда я нажимаю на ссылку, я просто захожу в профиль пользователя.
Контроллер пользователя
class UsersController < ApplicationController
filter_resource_access
# GET /users
# GET /users.xml
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /users/1
# GET /users/1.xml
def show
#@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
# GET /users/new
# GET /users/new.xml
def new
#@user = User.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
# GET /users/1/edit
def edit
#@user = User.find(params[:id])
end
def create
#@user = User.new(params[:user])
@user.channels << Channel.find(1)
respond_to do |format|
if @user.save
format.html { redirect_to(:channels, :notice => 'Registration successfully.') }
format.xml { render :xml => @user, :status => :created, :location => @user }
else
format.html { render :action => "new" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
def profile
@user = User.find(params[:id])
end
# PUT /users/1
# PUT /users/1.xml
def update
#@user = current_user
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.xml
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
def delete
@user = User.find(params[:user_id])
@user.destroy
redirect_to :users
end
end
Индекс Просмотр пользователя
<h1>Listing users</h1>
<p id="notice"><%= notice %></p>
<table>
<tr>
<th>Username</th>
<th>First Name</th>
<th>Last Name</th>
<th>Telephone</th>
<th>Email</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @users.each do |user| %>
<tr>
<td><%= user.login %></td>
<td><%= user.first_name %></td>
<td><%= user.last_name %></td>
<td><%= telephone_field_tag :phone, user.telephone ,:disabled => true %></td>
<td><%= email_field_tag :email, user.email, :disabled => true %></td>
<td><%= link_to 'View Profile', user %></td>
<td><%= link_to 'Edit Profile', edit_user_path(user) if permitted_to? :update ,user %></td>
<%if permitted_to? :delete ,user %>
<td><%= link_to 'Close Account', user, :method => :delete, :confirm => "Are you sure?" %></td>
<% end %>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New User', new_user_path %>