当我尝试提交表单以编辑用户详细信息时出现此错误。我正在使用 Rails 3.2.7。这是我的控制器
class UsersController < ApplicationController
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
end
end
def new
@user = User.new
end
def edit
@user = User.find(params[:id])
end
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Welcome to the app!"
redirect_to welcome_path
else
render 'new'
end
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
sign_in @user
flash[:success] = "Profile updated"
redirect_to welcome_path
else
render 'edit'
end
end
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
end
end
end
和形式:
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<p><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</p>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="box">
<%= f.label :email %>
<%= f.text_field :email, class:"input_text" %>
<br>
<%= f.label :"edit password" %>
<%= f.password_field :password, class:"input_text" %>
<br>
<label>
<br>
<%= f.submit "Save", class: "button", name: "button" %>
</label>
</div>
<% end %>
耙路线输出:
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
让我知道是否还有其他内容我应该发布...在此先感谢