Use our relationship appropriately
This commit is contained in:
parent
73cc9c24df
commit
846d6e6465
5 changed files with 17 additions and 7 deletions
1
Gemfile
1
Gemfile
|
@ -19,3 +19,4 @@ gem 'bootstrap-sass', '~> 3.2.0.2'
|
||||||
gem 'rb-readline'
|
gem 'rb-readline'
|
||||||
|
|
||||||
gem 'quiet_assets', group: :development
|
gem 'quiet_assets', group: :development
|
||||||
|
gem "bullet", :group => "development"
|
||||||
|
|
|
@ -31,6 +31,9 @@ GEM
|
||||||
bootstrap-sass (3.2.0.2)
|
bootstrap-sass (3.2.0.2)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
|
bullet (4.14.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
uniform_notifier (>= 1.6.0)
|
||||||
coffee-rails (4.0.1)
|
coffee-rails (4.0.1)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
|
@ -131,12 +134,14 @@ GEM
|
||||||
uglifier (2.5.3)
|
uglifier (2.5.3)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
json (>= 1.8.0)
|
json (>= 1.8.0)
|
||||||
|
uniform_notifier (1.6.2)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bootstrap-sass (~> 3.2.0.2)
|
bootstrap-sass (~> 3.2.0.2)
|
||||||
|
bullet
|
||||||
coffee-rails (~> 4.0.0)
|
coffee-rails (~> 4.0.0)
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
|
|
@ -2,7 +2,7 @@ class FriendshipsController < ApplicationController
|
||||||
before_action :require_login
|
before_action :require_login
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@friends = current_user.friends
|
@friendships = Friendship.includes(:friend).where(user_id: current_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -18,8 +18,7 @@ class FriendshipsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@friendship = Friendship.where(user_id: current_user.id,
|
@friendship = Friendship.find(params[:id])
|
||||||
friend_id: params[:id]).take
|
|
||||||
|
|
||||||
@friendship.destroy
|
@friendship.destroy
|
||||||
flash[:success] = 'Friend has been removed from your friends'
|
flash[:success] = 'Friend has been removed from your friends'
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @friends.each do |friend| %>
|
<% @friendships.each do |friendship| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= friend.name %></td>
|
<td><%= friendship.friend.name %></td>
|
||||||
<td><%= link_to 'Destroy', friendship_path(friend), method: :delete,
|
<td>[ <%= link_to 'Destroy', friendship, method: :delete,
|
||||||
data: { confirm: 'Are you sure?' } %></td>
|
data: { confirm: 'Are you sure?' } %> ]</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
5
config/initializers/bullet.rb
Normal file
5
config/initializers/bullet.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
if defined? Bullet
|
||||||
|
Bullet.enable = true
|
||||||
|
#Bullet.alert = true
|
||||||
|
Bullet.bullet_logger = true
|
||||||
|
end
|
Loading…
Reference in a new issue