-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
516 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.0.0 | ||
2.0.0-p247 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class RelationshipsController < ApplicationController | ||
before_filter :signed_in_user | ||
|
||
def create | ||
@user = User.find(params[:relationship][:followed_id]) | ||
current_user.follow!(@user) | ||
respond_to do |format| | ||
format.html { redirect_to @user } | ||
format.js | ||
end | ||
end | ||
|
||
def destroy | ||
@user = Relationship.find(params[:id]).followed | ||
current_user.unfollow!(@user) | ||
respond_to do |format| | ||
format.html { redirect_to @user } | ||
format.js | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: relationships | ||
# | ||
# id :integer not null, primary key | ||
# follower_id :integer | ||
# followed_id :integer | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Relationship < ActiveRecord::Base | ||
attr_accessible :followed_id | ||
|
||
belongs_to :follower, :class_name => "User" | ||
belongs_to :followed, :class_name => "User" | ||
|
||
validates :follower_id, :presence => true | ||
validates :followed_id, :presence => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$("#follow_form").html("<%= escape_javascript(render('users/unfollow')) %>") | ||
$("#followers").html('<%= @user.followers.count %>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$("#follow_form").html("<%= escape_javascript(render('users/follow')) %>") | ||
$("#followers").html('<%= @user.followers.count %>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% @user ||= current_user %> | ||
<div class="stats"> | ||
<a href="<%= following_user_path(@user) %>"> | ||
<strong id="following" class="stat"> | ||
<%= @user.followed_users.count %> | ||
</strong> | ||
following | ||
</a> | ||
<a href="<%= followers_user_path(@user) %>"> | ||
<strong id="followers" class="stat"> | ||
<%= @user.followers.count %> | ||
</strong> | ||
followers | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= form_for(current_user.relationships.build(:followed_id => @user.id), | ||
:remote => true) do |f| %> | ||
<div><%= f.hidden_field :followed_id %></div> | ||
<%= f.submit "Follow", :class => "btn btn-large btn-primary" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% unless current_user?(@user) %> | ||
<div id="follow_form"> | ||
<% if current_user.following?(@user) %> | ||
<%= render 'unfollow' %> | ||
<% else %> | ||
<%= render 'follow' %> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= form_for(current_user.relationships.find_by_followed_id(@user), | ||
:html => { :method => :delete }, | ||
:remote => true) do |f| %> | ||
<%= f.submit "Unfollow", :class => "btn btn-large" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<% provide(:title, @title) %> | ||
<div class="row"> | ||
<aside class="span4"> | ||
<section> | ||
<%= gravatar_for @user %> | ||
<h1><%= @user.name %></h1> | ||
<span><%= link_to "view my profile", @user %></span> | ||
<span><b>Microposts:</b> <%= @user.microposts.count %></span> | ||
</section> | ||
<section> | ||
<%= render 'shared/stats' %> | ||
<% if @users.any? %> | ||
<div class="user_avatars"> | ||
<% @users.each do |user| %> | ||
<%= link_to gravatar_for(user, :size => 30), user %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</section> | ||
</aside> | ||
<div class="span8"> | ||
<h3><%= @title %></h3> | ||
<% if @users.any? %> | ||
<ul class="users"> | ||
<%= render @users %> | ||
</ul> | ||
<%= will_paginate %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateRelationships < ActiveRecord::Migration | ||
def change | ||
create_table :relationships do |t| | ||
t.integer :follower_id | ||
t.integer :followed_id | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :relationships, :follower_id | ||
add_index :relationships, :followed_id | ||
add_index :relationships, [:follower_id, :followed_id], :unique => true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.