0
私にはトピックと投稿があり、どちらも関係があります。私はネストされた投稿を追加する方法についてのガイドに従ってきましたが、投稿に返信しようとするとCouldn't find Topic with 'id'=
が得られます。私Topics
コントローラ祖先の宝石でネストされた投稿を追加しようとしています
def show
@topic = Topic.find params[:id]
@post = Post.new(:parent_id => params[:parent_id])
@posts = @topic.posts
@topic.punch(request)
end
で
私Posts
コントローラで
def create
@topic = Topic.find params[:topic_id]
@post = Post.new(post_params)
@post.user_id = current_user.id
@post.topic_id = @topic.id
if @post.save
redirect_to @topic
else
render :new
end
end
私は私が私のトピック/ show.html.erbページ
に私の返信ボタンを持っているかの短縮にそれをしておこうこれは私の書式です
<%= simple_form_for [@topic, @post] do |f| %>
<%= f.hidden_field :parent_id %>
<%= f.input :content, as: :pagedown, input_html: { preview: true, rows: 10 }, label: 'Markdown' %>
<%= f.submit "Post", class: 'button expanded' %>
<% end %>
'params [:topic_id]'が 'create'にないようです。ルートファイル、 'create'の下のURL、リクエストのパラメータを表示できますか? –
遅く返事をして申し訳ありません。私は 'params [:topic_id]'が見つかりませんでした。ありがとう。 – Wesly