Ruby on rails Rails-表单行为怪异:不保存任何文本字段
在Matteo Alessani在年解决了我的问题后,我注意到我的表单没有保存我传递的字段 我将在这里复制另一个问题中的所有代码: 路线:Ruby on rails Rails-表单行为怪异:不保存任何文本字段,ruby-on-rails,ruby-on-rails-3,forms,Ruby On Rails,Ruby On Rails 3,Forms,在Matteo Alessani在年解决了我的问题后,我注意到我的表单没有保存我传递的字段 我将在这里复制另一个问题中的所有代码: 路线: resources :honors 型号: class Honor < ActiveRecord::Base belongs_to :person, :class_name => 'Person', :foreign_key => "person_id" belongs_to :honored, :class_name =>
resources :honors
型号:
class Honor < ActiveRecord::Base
belongs_to :person, :class_name => 'Person', :foreign_key => "person_id"
belongs_to :honored, :class_name => 'Person', :foreign_key => "honored_id"
belongs_to :group, :class_name => 'Group', :foreign_key => "group_id"
他认为:
<% @asked_groupmembership.each do |agm| %>
<%= link_to "Create Honor", new_honor_path(:group_id => @group.id,
:person => current_person.id, :honored => agm.member.id) %>
注意:日志中的参数与值一致
谢谢 控制器中有错误
def create
@person = Person.find(current_person)
@honor = Honor.new(params[:honor])
if @honor.save
flash[:success] = "Honor created."
redirect_to (:back)
else
redirect_to (:back)
end
end
我犯了一个更奇怪的错误。我将在显示我的新呼叫的代码中添加一个我忘记的片段。错误为:
Group(35572728)应为,get字符串(#3110088)app/controllers/honors\u controller.rb:25:in'new'app/controllers/honors\u controller.rb:25:in'create'
Hello。在表单视图中,它是@honor=honor.new(params[:honor])
当前的\u person.id%>@ordered.id%>:个人到:个人\u id,:荣幸到:荣幸的\u id
<% form_for @honor do |f| %>
<%= f.hidden_field :group_id, :value => @group.id %>
<%= f.hidden_field :person, :value => current_person.id %>
<%= f.hidden_field :honored, :value => @honored.id %>
<div class="field">
<%= f.label :texto %><br />
<%= f.text_field :texto %>
</div>
INSERT INTO "honors" ("group_id", "person_id", "honor_id", "texto", "nota",
"nivel_habilidade", "comprometimento", "tempo_demora",
"criatividade", "organicazao", "comunicacao", "trabalho_grupo", "created_at",
"updated_at") VALUES (39, 2, 44, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, '2011-05-26 12:58:56.433510', '2011-05-26 12:58:56.433510')
RETURNING "id".
def create
@person = Person.find(current_person)
@honor = Honor.new(params[:honor])
if @honor.save
flash[:success] = "Honor created."
redirect_to (:back)
else
redirect_to (:back)
end
end