Я работаю над приложением для форума, которое имеет 4 модели: Users
, Boards
, Topics
и Comments
. Мои маршруты:Вложенные ресурсы - неопределенный метод `comments_path '
resources :users do
resources :boards ### 'boards' contain 'topics'
resources :topics ### 'topics' are similar to 'posts'
resources :comments
end
resources :topics do
resources :comments
end
я называю метод link_to
в моих posts#show
действий с new_topic_comment_path
и передать переменную @topic
следующим образом:
<%=link_to "Leave a reply", new_topic_comment_path(@topic) %>
и в моих comments#new
зрения, у меня есть следующий вид:
<%=form_for @comment do |f| %>
<%=f.label :your_comment %>
<%=f.text_field :body %>
<%=f.submit "Post" %>
<%end%>
и вот мое comments#new
действие:
def new
@comment = Comment.new
@topic = Topic.find(params[:topic_id])
end
когда comments#new
загружается из topics#show
зрения, я получаю сообщение об ошибке говорящее undefined method "comments_path"