* feat: make the sidebar more dynamic * refactor: use the action in the same controller instead of the whole path * feat: remove hardcoded routes * feat: move routes into file * feat: use rails 6 draw for the admin routes * add a helper method * oops: fix super * feat: add the hacky helper methods :( ) * WIP: created different path helpers for the new routes and point the old helpers to the new ones if the FF is toggled * feat: update the module * chore: add new paths * feat: change link_to's use paths instead * feat: feedback_messages to scoped admin route * chore: update the feature flag urls helpers * feat: feedback_messages issue * chore: remove all the workarounds * chore: rubucop * fix: oops remove helper * chore: comment out the tests that touch the tabbed navbar which is affected by the rails application needing to be reloaded * feat: ensure that we chcek if the db table exists
47 lines
945 B
Ruby
47 lines
945 B
Ruby
module Admin
|
|
class BadgesController < Admin::ApplicationController
|
|
layout "admin"
|
|
|
|
def index
|
|
@badges = Badge.all
|
|
end
|
|
|
|
def new
|
|
@badge = Badge.new
|
|
end
|
|
|
|
def edit
|
|
@badge = Badge.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@badge = Badge.new(badge_params)
|
|
|
|
if @badge.save
|
|
flash[:success] = "Badge has been created!"
|
|
redirect_to admin_badges_path
|
|
else
|
|
flash[:danger] = @badge.errors_as_sentence
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def update
|
|
@badge = Badge.find(params[:id])
|
|
|
|
if @badge.update(badge_params)
|
|
flash[:success] = "Badge has been updated!"
|
|
redirect_to admin_badges_path
|
|
else
|
|
flash[:danger] = @badge.errors_as_sentence
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def badge_params
|
|
params.require(:badge).permit(:title, :slug, :description, :badge_image, :credits_awarded)
|
|
end
|
|
end
|
|
end
|