0
레일스에서 ancestry gem을 사용하고 있습니다. 모델에 설정하면 parent, parent_id, children 등과 같은 속성을 갖습니다. 이제 두 개의 속성을 포함하는 모델 메시지가 있습니다. content_title 및 우리는 parent_id 설정할 수 있지만 문제는 내가 그들 중 하나만 업데이트하려고 가져옵니다. 내 코드입니다.'ancestry'gem을 사용하여 레일의 속성 업데이트
은 "PARENT_ID은"업데이트 가져옵니다 "을 만들 행동"그리고 난이 단지 "PARENT_ID"처럼 업데이트 well.Now과 다른 두 속성에서 설정 만되고 난
#@page = Message.new(message_params)
를 사용할 때 다른 두 속성 인 content 및 content_title은 업데이트되고 parent_id는 업데이트되지 않습니다.
class MessagesController < ApplicationController
layout false
def index
@messages = Message.all
end
def show
@message_id = Message.find(params[:id])
end
def new
@message = Message.new
end
def create
@page = Message.new(:parent_id => params[:parent_id],:content_title => params[:content_title],:content => params[:content])
#@page = Message.new(message_params)
if @page.save
flash[:notice] = "The Mesage was created succeffully"
redirect_to(:action => 'index')
else
render('new')
end
end
private
def message_params
params.require(:message).permit(:parent_id,:content_title,:content)
end
end
이
데이터<div class="Pages new">
<h2> Create Pages</h2>
<%= form_for(:message, :url => {:action => 'create',:parent_id => @message_id}) do |f| %>
<table summary="Page form fields">
<tr>
<th>ParentID</th>
<td><%= f.text_field(:id) %></th>
</tr>
<tr>
<tr>
<th>Content Title</th>
<td><%= f.text_field(:content_title) %></th>
</tr>
<tr>
<th>Content</th>
<td><%= f.text_field(:content) %></th>
</tr>
</table>
<div class="form-buttons">
<%= submit_tag("Submit Form") %>
</div>
<% end %>
</div>
그들에게 내가 뭔가 잘못하고 모두 simultaneously.Am를 설정하는 방법이 있나요
을보기 파일을 보내는된다?