Class: GreenFlag::Admin::FeaturesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/green_flag/admin/features_controller.rb

Instance Method Summary collapse

Instance Method Details

#current_visitor_statusObject



27
28
29
30
31
# File 'app/controllers/green_flag/admin/features_controller.rb', line 27

def current_visitor_status
  @feature = GreenFlag::Feature.find(params[:id])
  fd = GreenFlag::FeatureDecision.for_feature(@feature.id).where(site_visitor_id: current_site_visitor.id).first
  render :json => { status: status_text(fd) }
end

#destroyObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/green_flag/admin/features_controller.rb', line 15

def destroy
  @feature = GreenFlag::Feature.where(id: params[:id]).first

  if @feature.present?
    destroy_feature
  else
    flash[:error] = "The feature could not be found."
  end

  redirect_to action: :index
end

#indexObject



5
6
7
# File 'app/controllers/green_flag/admin/features_controller.rb', line 5

def index
  @features = GreenFlag::Feature.order(:created_at).all
end

#showObject



9
10
11
12
13
# File 'app/controllers/green_flag/admin/features_controller.rb', line 9

def show
  @feature = GreenFlag::Feature.where(id: params[:id]).first

  @visitor_groups = GreenFlag::VisitorGroup.all.map { |group| { key: group.key, description: group.description } }
end