Rails - how do you create a user index page like stack overflows with multiple tabs whilst keeping t
Posted
by adam
on Stack Overflow
See other posts from Stack Overflow
or by adam
Published on 2010-04-13T10:00:02Z
Indexed on
2010/04/13
10:02 UTC
Read the original article
Hit count: 257
views
|ruby-on-rails
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.
© Stack Overflow or respective owner