當我提交表單駕駛員學校我得到這個錯誤:簡單形式的錯誤:mysql的::錯誤:列 'cached_slug'
的ActiveRecord :: StatementInvalid在KategorisController#創建
的Mysql ::錯誤:列' cached_slug」不能爲空:INSERT INTO kategoris
這裏是我的形式:
<%= simple_form_for(@kategori) do |f| %>
<%= f.input :name %>
<%= f.button :submit %>
<% end %>
這裏是我的控制器:
# GET /kategoris/new.xml
def new
@kategori = Kategori.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @kategori }
end
end
# GET /kategoris/1/edit
def edit
@kategori = Kategori.find(params[:id])
end
# POST /kategoris
# POST /kategoris.xml
def create
@kategori = Kategori.new(params[:kategori])
respond_to do |format|
if @kategori.save
format.html { redirect_to(@kategori, :notice => 'Kategori was successfully created.') }
format.xml { render :xml => @kategori, :status => :created, :location => @kategori }
else
format.html { render :action => "new" }
format.xml { render :xml => @kategori.errors, :status => :unprocessable_entity }
end
end
end
我應該將ID重命名爲friendly_id嗎?