added groups route thing

This commit is contained in:
nilsding 2015-01-12 06:57:43 +01:00
parent d1a6c512c4
commit f93624fa2c
3 changed files with 26 additions and 0 deletions

View File

@ -46,6 +46,17 @@ class UserController < ApplicationController
end
# endregion
# region Groups
def groups
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
@groups = if current_user == @user
@user.groups.all
else
@user.groups.where(private: false).all
end
end
# endregion
def followers
@title = 'Followers'
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!

View File

@ -0,0 +1,14 @@
.profile--header
.container.j2-page
.col-md-3.col-xs-12.col-sm-4
= render 'user/profile_info'
.hidden-xs= render 'shared/links'
.col-md-9.col-xs-12.col-sm-8
%h1.j2-lh.hidden-xs Groups
%h1.visible-xs Groups
%ul
- @groups.each do |group|
%li= group.title
.visible-xs= render 'shared/links'

View File

@ -89,6 +89,7 @@ Rails.application.routes.draw do
match '/@:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question
match '/@:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers, defaults: {page: 1}
match '/@:username/friends(/p/:page)', to: 'user#friends', via: 'get', as: :show_user_friends, defaults: {page: 1}
match '/@:username/groups(/p/:page)', to: 'user#groups', via: 'get', as: :show_user_groups, defaults: {page: 1}
match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1}
match '/:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer_alt
match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question_alt