Skip to content

Commit e1ed5bb

Browse files
activity first try
1 parent 4a2410a commit e1ed5bb

23 files changed

+4674
-46
lines changed

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ gem 'will_paginate', '~> 3.0'
6565

6666
gem 'sendgrid'
6767

68-
gem 'acts_as_votable','~> 0.10.0'
68+
gem 'acts_as_votable','~> 0.10.0'
69+
70+
gem 'public_activity'

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ GEM
7474
mime-types
7575
pg (0.17.1-x86-mingw32)
7676
polyglot (0.3.5)
77+
public_activity (1.4.1)
78+
actionpack (>= 3.0.0)
79+
activerecord (>= 3.0)
80+
i18n (>= 0.5.0)
81+
railties (>= 3.0.0)
7782
rack (1.5.2)
7883
rack-test (0.6.2)
7984
rack (>= 1.0)
@@ -149,6 +154,7 @@ DEPENDENCIES
149154
jquery-rails
150155
paperclip (~> 3.0)
151156
pg
157+
public_activity
152158
rails (= 4.0.2)
153159
rails_12factor
154160
sass-rails (~> 4.0.0)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/javascripts/courselist.js

Lines changed: 4512 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Place all the styles related to the activities controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
4+
.activity {
5+
border-bottom: solid 1px #ccc;
6+
padding: 16px 0;
7+
em {
8+
color: #777;
9+
font-size: 12px;
10+
padding-left: 5px;
11+
}
12+
}

app/assets/stylesheets/searchhome.css.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
margin-left:10px;
1717
}
1818
#course {
19-
margin-left:8%;
19+
margin-left:2%;
2020
}
2121
#year,#testname {
2222
margin-left:15px;
@@ -27,3 +27,4 @@
2727
#searchbox {
2828
margin-left:40%;
2929
}
30+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class ActivitiesController < ApplicationController
2+
def index
3+
@activities = PublicActivity::Activity.order("created_at desc").where(recipient_id: current_user, owner_type: "User")
4+
@myacts = PublicActivity::Activity.order("created_at desc").where(owner_id: current_user, owner_type: "User")
5+
end
6+
7+
#def destroy
8+
# @activity = PublicActivity::Activity.find(params[:id])
9+
# if @activity.destroy
10+
# redirect_to activities_url
11+
#end
12+
#end
13+
end

app/controllers/answers_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ class AnswersController < ApplicationController
44
def create
55
@question = Question.find(params[:question_id])
66
@answer = @question.answers.create(answer_params)
7-
@answer.user = current_user
8-
@answer.save
7+
@answer.user = current_user
8+
if @answer.save
9+
@answer.create_activity :create, owner: current_user, recipient: @question.user
910
redirect_to question_path(@question)
11+
end
1012

1113
end
1214

app/controllers/application_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class ApplicationController < ActionController::Base
2+
include PublicActivity::StoreController
23

34
# Prevent CSRF attacks by raising an exception.
45
# For APIs, you may want to use :null_session instead.

app/helpers/activities_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ActivitiesHelper
2+
end

0 commit comments

Comments
 (0)