Ruby on rails 3 该视图已调用,但未渲染

Ruby on rails 3 该视图已调用,但未渲染,ruby-on-rails-3,Ruby On Rails 3,我正在开发一个问答形式的项目,包括问题、答案和问题评论,我对这种结构有一个问题。我的路线图是: 经验简介-->讨论 因此,在这个项目中,我有一个带有一些信息的经验简介和一个链接 汇总所有问答结构的讨论。我的问题是,当我试图通过link_to访问讨论结构(Q&A)时,什么都没有呈现。我使用的是Rails 3.2.0和Ruby 1.9.3版本。我需要你的帮助 体验简介(链接到): <%= link_to "New topic", experience_discussions_path(@exp

我正在开发一个问答形式的项目,包括问题、答案和问题评论,我对这种结构有一个问题。我的路线图是:

经验简介-->讨论

因此,在这个项目中,我有一个带有一些信息的经验简介和一个链接 汇总所有问答结构的讨论。我的问题是,当我试图通过link_to访问讨论结构(Q&A)时,什么都没有呈现。我使用的是Rails 3.2.0和Ruby 1.9.3版本。我需要你的帮助

体验简介(链接到):

<%= link_to "New topic", experience_discussions_path(@experience), :remote => true %></p>
respond_to :html, :json
def index
    @experience = Experience.find(params[:experience_id])
    @question = Question.new
    @questions = Question.where(:experience_id => @experience.id).order('updated_at desc')

respond_with(@experience, @questions) do |format|
    format.html { render :layout => !request.xhr? }
end
end

def create
    @experience  = Experience.find(params[:experience_id])
    @question = @experience.questions.new(params[:question])
    @question.user = current_user
if @question.save
    flash[:notice] = 'Pergunta criada com sucesso'
else
    respond_with(@experience, @question) do |format|
    format.html { redirect_to experience_path(@experience)+'#discussion' }
    end
end
<div id="questions">
<%= form_for(@question, :url => experience_discussions_path, :method => 'post') do |f| %><br />
<fieldset class ="new_question">
<div class="field">
    <%= f.label "Ask question" %>
    <%= f.text_field :title %>
</div>
<div class="field">
    <%= f.submit "Create", :class => 'button' %>
</div>
</fieldset>
<% end %>

<% @questions.each do |q| %>
<h3 id="q_title">
    <%= (:question) %>: <%= q.title %><br />
    <small> <%= (:question_from) %> <%= q.user %></small>
</h3>

<%= form_for(Answer.new(:question => q),:url => experience_discussion_answers_path(@experience, q),:method => 'post') do |f| %>
<fieldset class="new_answer">
<div class="field">
    <%= f.label "Resposta" %>
    <%= f.text_area :body %>
</div>
<div class="field">
    <%= f.submit "Create", :class => 'button' %>
</div>
</fieldset>
<% end if current_user == @experience.user && q.answers.empty? %>

<% q.answers.each do |answer|%> 
    <p><%= answer.body %></p> 
<% end %>

<% q.comments.each do |comment|%>
    <p <%= 'class=owner' if comment.user == @experience.user%> >
    <small><%= user_link comment.user %></small>
    <br>
    <%= comment.body %>
    </p>
<% end unless q.answers.empty? %>  
<%= link_to("Add comment"), experience_discussion_comments_path(@experience, q)) %>
<%= render(:partial => 'question_comment') %>
<% end %>
</div>
讨论视图(索引):

<%= link_to "New topic", experience_discussions_path(@experience), :remote => true %></p>
respond_to :html, :json
def index
    @experience = Experience.find(params[:experience_id])
    @question = Question.new
    @questions = Question.where(:experience_id => @experience.id).order('updated_at desc')

respond_with(@experience, @questions) do |format|
    format.html { render :layout => !request.xhr? }
end
end

def create
    @experience  = Experience.find(params[:experience_id])
    @question = @experience.questions.new(params[:question])
    @question.user = current_user
if @question.save
    flash[:notice] = 'Pergunta criada com sucesso'
else
    respond_with(@experience, @question) do |format|
    format.html { redirect_to experience_path(@experience)+'#discussion' }
    end
end
<div id="questions">
<%= form_for(@question, :url => experience_discussions_path, :method => 'post') do |f| %><br />
<fieldset class ="new_question">
<div class="field">
    <%= f.label "Ask question" %>
    <%= f.text_field :title %>
</div>
<div class="field">
    <%= f.submit "Create", :class => 'button' %>
</div>
</fieldset>
<% end %>

<% @questions.each do |q| %>
<h3 id="q_title">
    <%= (:question) %>: <%= q.title %><br />
    <small> <%= (:question_from) %> <%= q.user %></small>
</h3>

<%= form_for(Answer.new(:question => q),:url => experience_discussion_answers_path(@experience, q),:method => 'post') do |f| %>
<fieldset class="new_answer">
<div class="field">
    <%= f.label "Resposta" %>
    <%= f.text_area :body %>
</div>
<div class="field">
    <%= f.submit "Create", :class => 'button' %>
</div>
</fieldset>
<% end if current_user == @experience.user && q.answers.empty? %>

<% q.answers.each do |answer|%> 
    <p><%= answer.body %></p> 
<% end %>

<% q.comments.each do |comment|%>
    <p <%= 'class=owner' if comment.user == @experience.user%> >
    <small><%= user_link comment.user %></small>
    <br>
    <%= comment.body %>
    </p>
<% end unless q.answers.empty? %>  
<%= link_to("Add comment"), experience_discussion_comments_path(@experience, q)) %>
<%= render(:partial => 'question_comment') %>
<% end %>
</div>

经验讨论路径:方法=>'post')do | f |%>
'按钮'%> :
q) ,:url=>experience\u discussion\u answers\u path(@experience,q),:method=>'post')do | f |%> '按钮'%>

如果comment.user==@experience.user%>

“问题(评论)”)%>
删除所有那些respond\u to和respond\u with code,让rails显示一些错误,您将看到其中缺少了什么,我想您需要在方法上对format.js进行响应,并拥有.js.erb视图

检查日志并查看发送到服务器的请求的格式