just now i starting to study ruby on rails ruby version=1.8.7 rails version =2.3.2
help me
i create delete and create new user action but present some error the error is
uninitialized constant User::Id
Extracted source (around line #19):
16: <td><%= user.fname %></td>
17: <td><%= user.lname %></td>
18: <td><%= user.dob %></td>
19: <td><%= button_to "delete", :url => {:controller => :users,:action => 'destroy',:id =>user.id}, :method => :delete %></td>
20: </tr>
21: <% end %>
22: </table>
my mysql database table is
id fname lname dob
1 kamal vimal 2012.02.12
2 rahu sharmi 2012.05.26
3 mithun kavi 2012.03.07
class User < ActiveRecord::Base
set_primary_key :id
has_one :id
end
my controller is
class UsersController < ApplicationController
def index
@users=User.all
end
def destroy
# User.primary_key='id'
@users=User.find(:id)
@users.destroy
flash[:notice] = "You have successfully Delete Recode"
end
def new
@users=User.new
end
def create
@users=User.new(params[:users])
if @user.save
redirect_to_users_path
flash[:notice] = "Your record is created!"
else
render :action => "index"
end
end
end
my view is
<% @users.each do |user| %>
<%= button_to "delete", :url => {:controller => :users,:action => 'destroy',:id =>user.id}, :method => :delete %>
<% end %>
anyone help me?
Aucun commentaire:
Enregistrer un commentaire