"topics_controller"내의 쇼에서 액세스하려고 시도하는 "topics_controller"에서 "createpost"라는 메서드가 있지만 경로 오류가 계속 발생합니다.form_for route error [RoR]
폼 :
는 컨트롤러 액션이<%= form_for @community_post, :url => { :action => "createpost", :controller=> "community_topics" } do |f| %>
<%= render 'error_messages' %>
<%= f.label :text %>
<%= f.text_area :text %>
<%= hidden_field_tag :community_topic_id, @community_topic.id %>
<br>
<%= f.submit "Submit reply" %>
: 내가 잘못 뭐하는 거지
def createpost
@community_post = CommunityPost.new(community_post_params)
@community_post.user_id = current_user.id
@community_post.community_topic_id = params[:community_topic_id]
if @community_post.save
redirect_to "/community_topics/#{@community_post.community_topic_id}", notice: 'Community post was successfully created.'
else
render action: 'new'
end
end
그래서 그것을 수정할 수 있습니까? 무리 감사.
resources :comunity_topics do
post 'createpost', action: 'createpost'
end
및 양식 경로가 같은 것을해야한다 :
createpost_comunity_topics_path
이 routes.rb''의 관련 부분을 포함하시기 바랍니다. 'createpost'라는 멤버 액션에 대한 경로가 정의되어 있습니까? –
필자는 필자가 필요하다고 생각하지 않았다. 필자의 응용 프로그램 내에서 누군가를 위해 공개적으로 라우트되지 않아야하기 때문이다. 지금 당장 가지고있는 리소스는 다음과 같습니다. community_topics 리소스 : community_posts와 관련하여 –
적어도 라우팅 오류를 표시 할 수 있습니까? topics_controller와 community_topics 컨트롤러를 지정했습니다. – deepthi