Estoy renderizando vistas mediante AJAX en un tab-pannel, y todas me funcionan menos cuando quiero renderizar _show.html.erb al hacer submit en el form del partial _new.html.erb. A ver si alguien me puede echar una mano.
controlador
class TopicsController < ApplicationController
before_action :find_topic, only: [:show, :edit, :update, :destroy]
def index
@topics = Topic.all
respond_to do |format|
format.js
end
end
def show
respond_to do |format|
flash[:notice] = "Topic successfully created"
format.js {redirect_to :controller=> "topics", :action=>"show", :topic=> @topic}
end
end
def new
@topic = Topic.new
respond_to do |format|
format.js
end
end
def create
@topic = Topic.new(topic_params)
@topic.user_id = current_user.id if current_user
if @topic.save
flash[:notice] = "Topic successfully created"
respond_to do |format|
format.js {redirect_to :controller=> "topics", :action=>"show", :topic=> @topic}
format.html
end
end
parte del form
<div id="forumActivity">
<%= form_for @topic, :remote => true do |f| %>
<%= f.hidden_field :competition_id, :value => params[:competition_id], class: "idcomp form-control" %>
<%= f.label :title %>
<%= f.text_field :title, rows: 2, placeholder: "Write the title...", class: 'form-control' %>
<%= f.label :content %>
<%= f.text_area :content, rows: 10, placeholder: "Write the content...", class: 'form-control' %>
<br>
<%= f.submit 'Create Topic', class: 'btn btn-primary btn-sm' %>
<% end %>
</div>
create.js.erb
$("#forumActivity").html("<%= escape_javascript(render partial: 'topics/show' locals: { topic: @topic }) %>");
$('#comments').html("<%=j render @topic.comments %>");
show.js.erb
$("#forumActivity").html("<%= escape_javascript(render partial: 'topics/show', locals: { topic: @topic } ) %>");