I was researching here on SO how to implement a tabbed interface in my Rails app. For example, I like how Ryan Bates uses it in his Railscast overview page. 
I want to mimic that in my Rails app so that a User’s profile has a navigation in it with two or three links. Clicking either link loads information using AJAX (I’m guessing). Then the URL shows /profiles/1/view?info or /profiles/1/view?otherdata
I came across this question, with the following solution:
I would make the contents of each tab be called in by a separate ajax request. This would give you the following benefits
- Now each tab can easily be a different view/controller
- You only need to load the contents for a tab when it is used; you won’t be processing code/downloading html for tabs that the user doesn’t use.
The problem is I’m new to Rails and have no idea how to do this. Can anyone point me to some resources that help explain how to set this up? I’d be tabbing between profile data and messages to the user.
Any help would be much appreciated.
As you’re new to Rails I’d suggest breaking up your goal into 2 sections: first, get the tabs working with simple content, then add the AJAX.
Step 1 – Getting the tabs working
Have a look at the JQuery UI tabs demos: http://jqueryui.com/demos/tabs/
The code looks something like this:
Step 2 – Getting the AJAX working
Check out: http://jqueryui.com/demos/tabs/#ajax