Class: Muck::ActivitiesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Muck::ActivitiesController
show all
- Includes:
- ApplicationHelper, MuckActivityHelper
- Defined in:
- app/controllers/muck/activities_controller.rb
Instance Method Summary
collapse
#activity_comment_link, #activity_comments, #activity_feed_for, #activity_filter, #activity_for, #activity_scripts, #all_activities_url, #cached_activities, #contribute, #current_status, #delete_activity, #delete_activity_comment, #get_activities, #get_profile_activities, #has_comments_css, #is_current_filter?, #limited_activity_feed_for, #no_filter?, #status_update
Instance Method Details
#create ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/muck/activities_controller.rb', line 21
def create
@activity = @parent.activities.build(params[:activity])
@activity.source = @parent
@activity.content.gsub!(@parent.display_name, '') if @activity.template == 'status_update'
@parent.save!
@activity_html = get_activity_html(@activity)
if @activity.template == 'status_update'
@status_html = get_status_html(@parent)
else
@status_html = ''
end
respond_to do |format|
format.js { render :template => 'activities/create', :layout => false }
format.html { redirect_back_or_default(@parent) }
format.json do
render :json => { :success => true,
:is_status_update => @activity.is_status_update,
:html => @activity_html,
:status_html => @status_html,
:message => t("muck.activities.created") }
end
end
rescue ActiveRecord::RecordInvalid => ex
if @activity
errors = @activity.errors.full_messages.to_sentence
else
errors = ex
end
message = t('muck.activities.update_error', :errors => errors)
respond_to do |format|
format.html do
flash[:error] = message
redirect_back_or_default(@parent)
end
format.js { render :js => message }
format.json do
render :json => { :success => false,
:exception => ex,
:message => t("muck.activities.create_error", :error => errors) }
end
end
end
|
#destroy ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'app/controllers/muck/activities_controller.rb', line 67
def destroy
@activities_object = @activity.source
@activity.destroy
respond_to do |format|
format.html do
flash[:notice] = t("muck.activities.item_removed")
redirect_back_or_default(@activities_object)
end
format.js do
@new_status = get_status_html(@activities_object) if @activity.is_status_update
render :template => 'activities/destroy', :layout => false
end
format.json do
@new_status = get_status_html(@activities_object) if @activity.is_status_update
render :json => { :success => true,
:is_status_update => @activity.is_status_update,
:html => @new_status,
:message => t("muck.activities.item_removed") }
end
end
rescue => ex
respond_to do |format|
format.html do
flash[:notice] = t("muck.activities.item_could_not_be_removed")
redirect_back_or_default(current_user)
end
format.js { page_alert(t("muck.activities.item_could_not_be_removed")) }
format.json { render :json => { :success => false, :message => t("muck.activities.item_could_not_be_removed") } }
end
end
|
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/muck/activities_controller.rb', line 10
def index
if @parent.can_view?(current_user)
@activities = get_activities(@parent)
else
@activities = get_profile_activities(@parent) end
respond_to do |format|
format.js { render :text => get_activities_html(@activities) }
end
end
|