Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shu1985 committed Apr 7, 2012
1 parent b59a7c4 commit a7d994f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ class RoomsController < ApplicationController
# index #
#-------#
def index
@rooms = Room.order( "created_at DESC" ).includes( :user ).all
@rooms = Room.order( "created_at DESC" ).includes( :user )
@exist_me = @rooms.where( user_id: session[:user_id] ).exists?

@room = Room.new
end

#------#
# show #
#------#
def show
@room = Room.where( id: params[:id] ).first
@tweets = Tweet.where( room_id: params[:id] ).order( "created_at DESC" ).includes( :user )
room_id = params[:id]

@room = Room.where( id: room_id ).first
@tweets = Tweet.where( room_id: room_id ).order( "created_at DESC" ).includes( :user )

# Twitterから取得
get_twitter_hash = Tweet.get_twitter_param( @room )
Expand Down
10 changes: 7 additions & 3 deletions app/views/rooms/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
<th style="white-space: nowrap;">MaxID</th>
<th style="white-space: nowrap;">SearchQuery</th>
<th></th>
<% if @exist_me %>
<th></th>
<th></th>
<% end %>
</tr>

<% @rooms.each do |room| %>
Expand All @@ -65,13 +67,15 @@
<td style="white-space: nowrap;"><%= room.search_query %></td>

<td><%= link_to "Show", { action: 'show', id: room.id } %></td>

<% if session[:user_id] == room.user_id or current_user.is_super? %>
<td><%= link_to "Edit", { action: 'edit', id: room.id } %></td>
<td><%= link_to "Delete", { action: 'delete', id: room.id }, onClick: "return confirm('「#{room.hash_tag}」を削除します。よろしいですか?');" %></td>
<% else %>
<td></td>
<td></td>
<td></td>
<% if @exist_me %>
<td></td>
<td></td>
<% end %>
<% end %>
</tr>
<% end %>
Expand Down

0 comments on commit a7d994f

Please sign in to comment.