Renderize três parciais diferentes, dependendo do botão clicado
Então, eu tenho um layout como este:
home / index.html.erb:
<div class="optionscontainer btn-group btn-group-justified">
<%= link_to posts_path, class:"options btn btn-primary", remote: true do %>
<i class="fa fa-book optionseach" aria-hidden="true"></i>All posts
<% end %>
<%= link_to stories_path, class:"options btn btn-primary", remote: true do %>
<i class="fa fa-book optionseach" aria-hidden="true"></i>All stories
<% end %>
</div>
<div id="content" class="">
</div>
Em posts_controller.rb
Eu tenho:
def index
@posts = Post.all
respond_to do |format|
format.html #looks for views/books/index.html.erb
format.js #looks for views/books/index.js.erb
end
end
Em stories_controller.rb
Eu tenho:
def index
@stories = Story.all
respond_to do |format|
format.html #looks for views/books/index.html.erb
format.js #looks for views/books/index.js.erb
end
end
Na minha opinião / posts / index.js.erb
$("#content").html("<%= j (render 'posts') %>");
Na minha opinião / stories / index.js.erb
$("#content").html("<%= j (render 'stories') %>");
E eu também tenho_posts.html.erb
noviews/posts
e_stories_html.erb
noviews/stories
O que acontece é que, quando clico no botão de postagens, renderiza a visualização, mas quando clico no botão de histórias, nada é renderizado?