Class: SesDashboard::ProjectsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SesDashboard::ProjectsController
- Defined in:
- app/controllers/ses_dashboard/projects_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 27 def create @project = Project.new(project_params) if @project.save redirect_to project_path(@project), notice: "Project created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
46 47 48 49 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 46 def destroy @project.destroy redirect_to projects_path, notice: "Project deleted." end |
#edit ⇒ Object
36 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 36 def edit; end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 5 def index @projects = Project.ordered end |
#new ⇒ Object
23 24 25 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 23 def new @project = Project.new end |
#show ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 9 def show from = parse_date(params[:from]) || 30.days.ago.beginning_of_day to = parse_date(params[:to]) || Time.current.end_of_day agg = StatsAggregator.new(project_id: @project.id, from: from, to: to) @counters = agg.counters @total_opens = agg.total_opens @total_clicks = agg.total_clicks @chart_data = agg.time_series @from = from @to = to end |
#update ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/controllers/ses_dashboard/projects_controller.rb', line 38 def update if @project.update(project_params) redirect_to project_path(@project), notice: "Project updated." else render :edit, status: :unprocessable_entity end end |