Skip to content

Commit

Permalink
Routes fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalimaha committed Apr 27, 2016
1 parent d0d88dd commit 761f3d0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
6 changes: 5 additions & 1 deletion app/controllers/user_controller.rb
Expand Up @@ -48,7 +48,11 @@ def create_following
def list
ids = @redis.hvals('users')
@users = []
ids.each {|id| @users << get_user(id)}
ids.each do |id|
user = get_user(id)
user['user_id'] = id
@users << user
end
@follower_id = get_user_id(params[:username].downcase)
@users
end
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/user_helper.rb
Expand Up @@ -12,7 +12,8 @@ def get_next_id

def create_user(user)
user_id = get_next_id
@redis.hset('users', user[:username], user_id)
username = user[:username] != nil ? user[:username] : user['username']
@redis.hset('users', username, user_id)
@redis.mapped_hmset(user_id, user)
end

Expand Down
25 changes: 17 additions & 8 deletions app/views/tweet/retrieve.html.erb
Expand Up @@ -12,14 +12,6 @@
style: 'width: 100%;'%>
</h1>
</div>
<div class="col-lg-2">
<h1>
<%= link_to '<i class="fa fa-magic"></i> New Tweet'.html_safe,
'/tweets/' + @username + '/new',
class: 'btn btn-primary pull-right',
style: 'width: 100%;'%>
</h1>
</div>
<div class="col-lg-2">
<h1>
<%= link_to '<i class="fa fa-users"></i> Show Users'.html_safe,
Expand All @@ -28,6 +20,23 @@
style: 'width: 100%;'%>
</h1>
</div>
<div class="col-lg-2">
<% if session[:username] == @username %>
<h1>
<%= link_to '<i class="fa fa-magic"></i> New Tweet'.html_safe,
'/tweets/' + @username + '/new',
class: 'btn btn-primary pull-right',
style: 'width: 100%;'%>
</h1>
<% else %>
<h1>
<%= link_to '<i class="fa fa-magic"></i> New Tweet'.html_safe,
'/tweets/' + @username + '/new',
class: 'btn btn-primary pull-right disabled',
style: 'width: 100%;'%>
</h1>
<% end %>
</div>
</div>

<hr style="margin-top: 0;">
Expand Down
8 changes: 4 additions & 4 deletions app/views/user/list.html.erb
Expand Up @@ -6,10 +6,10 @@

<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Follow</th>
</tr>
<tr>
<th>Username</th>
<th>Follow</th>
</tr>
</thead>
<tbody>
<% @users.each do |u| %>
Expand Down

0 comments on commit 761f3d0

Please sign in to comment.