我尝试为我的桌面对象设置rails控制台,但是当我安装魔法或者formtastic(我不知道)时,我的记录不会保存。
模型
class Depositi < ActiveRecord::Base
attr_accessible :code, :description
validates_presence_of :code, :message => 'Code required!'
end
查看
<%= semantic_form_for(@depositi) do |f| %>
<%= f.inputs 'Dati Deposito' do %>
<%= f.input :code, :label => 'Codice Deposito:' , :wrapper_html => { :class => 'fl' }, :required => true %>
<%= f.input :description, :label => 'Descrizione:', :wrapper_html => { :class => 'fl'}, :input_html => {:size => '15'} %>
<% end %>
<%= f.actions do %>
<%= f.action :submit, :as => :button, :label => 'Save' %>
<% end %>
<% end %>
这是我的调试:
utf8 ✓
authenticity_token kVQ5OOkmGxqoZgbvteJ80M+lLHwopWEY0SI4YetQYsg=
depositi {"code":"001","description":"Test this is test"}
button
action new
控制器
def create
@depositi = Depositi.new(params[:depositi])
respond_to do |format|
if @depositi.save
format.html { redirect_to @depositi, notice: 'Record salvato con successo!' }
format.json { render json: @depositi, status: :created, location: @depositi }
else
format.html { render action: "new" }
format.json { render json: @depositi.errors, status: :unprocessable_entity }
end
end
端
此记录不保存!我是财产登录,我没有错误..为什么不保存?
已解决:问题出现在我的视图中&lt;%= semantic_form_for(@ depositi)do | f | %GT; 我写的那与formtastic渲染形式有冲突。