Rails - how do you create a user index page like stack overflows with multiple tabs whilst keeping t
- by adam
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.