dashboards_controller.rb 681 B

123456789101112131415161718192021222324252627282930313233343536
  1. module Blazer
  2. class DashboardsController < BaseController
  3. before_action :set_dashboard, only: [:show, :edit, :update, :destroy]
  4. def index
  5. @dashboards = Blazer::Dashboard.order(:name)
  6. end
  7. def new
  8. @dashboard = Blazer::Dashboard.new
  9. end
  10. def create
  11. @dashboard = Blazer::Dashboard.new(dashboard_params)
  12. if @dashboard.save
  13. redirect_to dashboard_path(@dashboard)
  14. else
  15. render :new
  16. end
  17. end
  18. def show
  19. end
  20. protected
  21. def dashboard_params
  22. params.require(:dashboard).permit(:name)
  23. end
  24. def set_dashboard
  25. @dashboard = Blazer::Dashboard.find(params[:id])
  26. end
  27. end
  28. end