Got this job, it was very easy at the end.
Step 1 - Add :remote => true to the links in the sidebar
#application.html.haml %nav#sidebar - for post in @posts = link_to post.title, post_path, :remote => true %div#main = yield
Step 2 - tell your controller to respond to JS in show action
def show @post = Post.find(params[:id]) @posts=Post.all
Step 3 Create _post.html.haml
Step 4 Create show.js.erb and replace the html in the #main div with the contents of the _post part (which we created in step 3)
# show.js.erb $("#main").html("<%= escape_javascript(render @post) %>");
Now all the content is passed through ajax and it works fine.
stephenmurdoch
source share