Class: ProjectsController
Instance Method Summary
collapse
#display_uservoice_sso, #render_facebook_like, #render_facebook_sdk, #render_twitter
Instance Method Details
#create ⇒ Object
40
41
42
43
44
45
46
|
# File 'app/controllers/projects_controller.rb', line 40
def create
@project = current_user.projects.new(params[:project])
create!(notice: t('projects.create.success')) do |success, failure|
success.html{ return redirect_to project_by_slug_path(@project.permalink) }
end
end
|
#embed_panel ⇒ Object
74
75
76
77
|
# File 'app/controllers/projects_controller.rb', line 74
def embed_panel
@title = resource.name
render layout: false
end
|
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/projects_controller.rb', line 10
def index
index! do |format|
format.html do
if request.xhr?
@projects = apply_scopes(Project).visible.order_for_search.includes(:project_total, :user, :category).page(params[:page]).per(6)
return render partial: 'project', collection: @projects, layout: false
else
@title = t("site.title")
if current_user && current_user.recommended_projects.present?
@recommends = current_user.recommended_projects.limit(3)
else
@recommends = ProjectsForHome.recommends
end
@channel_projects = Project.from_channels.order_for_search.limit(3)
@projects_near = Project.online.near_of(current_user.address_state).order("random()").limit(3) if current_user
@expiring = ProjectsForHome.expiring
@recent = ProjectsForHome.recents
end
end
end
end
|
#new ⇒ Object
33
34
35
36
37
38
|
# File 'app/controllers/projects_controller.rb', line 33
def new
new! do
@title = t('projects.new.title')
@project.rewards.build
end
end
|
#show ⇒ Object
55
56
57
58
59
60
|
# File 'app/controllers/projects_controller.rb', line 55
def show
@title = resource.name
fb_admins_add(resource.user.facebook_id) if resource.user.facebook_id
@updates_count = resource.updates.count
@update = resource.updates.where(id: params[:update_id]).first if params[:update_id].present?
end
|
#update ⇒ Object
48
49
50
51
52
53
|
# File 'app/controllers/projects_controller.rb', line 48
def update
update! do |success, failure|
success.html{ return redirect_to project_by_slug_path(@project.permalink, anchor: 'edit') }
failure.html{ return redirect_to project_by_slug_path(@project.permalink, anchor: 'edit') }
end
end
|
#video ⇒ Object
62
63
64
65
|
# File 'app/controllers/projects_controller.rb', line 62
def video
project = Project.new(video_url: params[:url])
render json: project.video.to_json
end
|