Class: AdController
- Inherits:
-
KitController
- Object
- ActionController::Base
- KitController
- AdController
- Defined in:
- app/controllers/ad_controller.rb
Constant Summary
Constants inherited from KitController
Instance Attribute Summary
Attributes inherited from KitController
#is_image_request, #kit_request, #layout_being_used, #requested_url, #template_being_used
Instance Method Summary collapse
Methods inherited from KitController
#anti_spam_okay?, #app_name, #can_moderate, #can_use, #captcha_okay?, #check_and_record_goal, #check_user, #csv_headers, #dif, #edit_page_path, #feature?, #get_asset, #get_view_content, #host_name, #index_name, #info_page_path, #kit_layout_in_use, #kit_render, #kit_session, #kit_session_end, #link_to, #mailchimp_connect, #mobile_template, #no_read, #no_write, #not_found, #not_found_404, #offline, #page_path, #pref, #rails_app_name, #render, #render_error, #render_page, #render_page_by_url, #routing_error, #sanity_check_okay?, #session_id, #set_requested_url, #show_form, #stylesheets, #super_render, #user_sees_menu?
Instance Method Details
#buy ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/ad_controller.rb', line 3 def buy = JSON.parse(params[:options]) @ad = Ad.new(params[:ad]) @ad.duration = params[:ad][:duration].to_i zone = AdZone.find_sys_id(_sid, params[:zones].first) @ad.height = zone.height @ad.width = zone.width @ad.system_id = _sid @ad.name = params[:ad][:name] @ad.start_date = params[:ad][:start_date] @ad.user_id = current_user.id @ad.end_date = @ad.start_date + @ad.duration.send(zone.period.downcase) rescue nil @ad.activated = nil if @ad.save price = 0 params[:zones].each do |z| next unless ["zones"].include?(z.to_i) zone = AdZone.find_sys_id(_sid, z) @ad.ad_zones << zone end @ad.price_paid = @ad.cost @ad.tax_rate = @ad.current_tax_rate @ad.save else logger.debug @ad.errors..join(' ') redirect_to ["failed"] and return end redirect_to "#{['success']}?ad_id=#{@ad.id}" end |
#clicked ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/ad_controller.rb', line 35 def clicked ad = Ad.find_sys_id(_sid, params[:id]) redirect_to "/", :notice=>"Ad not found" and return unless ad AdClick.create(:ad=>ad, :user=>current_user, :referrer=>request.referer, :ip=>request.remote_ip) unless params[:admin] redirect_to ad.link end |