Class: RiactionGenie::EventsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/riaction_genie/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/riaction_genie/events_controller.rb', line 16

def create
  if @profile.riaction_profile_keys.has_key?(params[:profile_type].try(:to_sym)) && params[:event_name].present?
    IActionable::Api.new.log_event( params[:profile_type].to_s,
                                    @profile.riaction_profile_keys[params[:profile_type].to_sym].first.first.to_s,
                                    @profile.riaction_profile_keys[params[:profile_type].to_sym].first.last.to_s,
                                    params[:event_name].to_s,
                                    Rack::Utils.parse_nested_query(params[:event_params]) )
    respond_to do |format|
      format.json { render json: {  id: @profile.id, 
                                    profile_type: params[:profile_type], 
                                    event_name: params[:event_name], 
                                    event_params: params[:event_params]
                                    }, status: :created }
    end
  else
    respond_to do |format|
      format.json {render :nothing => true, :status => :unprocessable_entity}
    end
  end
end

#indexObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/riaction_genie/events_controller.rb', line 6

def index
  @events = []
  Riaction::Riaction::EVENT_CLASSES.each do |class_name|
     klass = class_name.constantize
     klass.riaction_events.each_pair do |name, deets|
       @events << name
     end
   end
end