Using Rails 3 and jquery, I'm trying to setup a simple 3 tab navigation for my post#show page, rendering _post _comments and _related partials into the view when clicked.
These partials don't have their own controller actions, currently.
What would be the cleanest Rails way to handle these ajax calls?
I tried this but it's not working:
Post controller:
def tab
respond_to do |format|
format.js
end
end
Post show view:
<%= link_to "Comments", {:action => 'tab'}, :remote => true %>
/views/posts/tab.js.erb
$('#postshow').html("<%= escape_javascript(render('comments')) %>");
However, if I do this, when I try to open my Track Show page i get hungup with this error "No route matches {:action=>"tab", :controller=>"posts"}"
i thought i defined an action for tab that should render the tab.js.erb... But more importantly this seems a little clunky to just switch around between three partials.
Any help is much appreciated. Thanks.