I've decided to reopen this because I want to here more peoples views on this. I'm not looking for full code but rather your approach.
Stackoverflows user profile (user index) is pretty complex, it has around 7 tabs, each one displaying the data in different way. Its almost like they are mini views each one using a different partial for the tabulated data. I'm still relatively new to rails and know how to use partials but can't see how they alone can solve this.
Im also wondering how do you avoid using a huge if else statement in the master index view to detect which tab/ mini-view to display. For stackoverflow that would be around 7 case statements.
END EDIT.
original question follows.
On stackoverflow in the users profile area there are many tabs which all display differing information such as questions asked and graphs. Its the same view though and im wondering hows its best to achieve this in rails whilst keeping the controller skinny and logic in the view to a minimum.
def index
@user = current_user
case params[:tab_selected]
when "questions"
@data = @user.questions
when "answers"
@sentences = @user.answers
else
@sentences = @user.questions
end
respond_to do |format|
format.html # index.html.erb
nd
end
but how do i process this in the index view without a load of if and else statments. And if questions and answers are presented differently whats the best way to go about this.