Class: AdsController

Inherits:
BaseController show all
Defined in:
app/controllers/ads_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index

Methods included from LocalizedApplication

#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale

Methods included from AuthenticatedSystem

#login_by_token, #update_last_seen_at

Instance Method Details

#createObject

POST /ads POST /ads.xml



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/ads_controller.rb', line 40

def create
  @ad = Ad.new(params[:ad])

  respond_to do |format|
    if @ad.save
      flash[:notice] = :ad_was_successfully_created.l
      format.html { redirect_to ad_url(@ad) }
    else
      format.html { render :action => "new" }
    end
  end
end

#destroyObject

DELETE /ads/1 DELETE /ads/1.xml



70
71
72
73
74
75
76
77
78
# File 'app/controllers/ads_controller.rb', line 70

def destroy
  @ad = Ad.find(params[:id])
  @ad.destroy

  respond_to do |format|
    format.html { redirect_to ads_url }
    format.xml  { head :ok }
  end
end

#editObject

GET /ads/1;edit



34
35
36
# File 'app/controllers/ads_controller.rb', line 34

def edit
  @ad = Ad.find(params[:id])
end

#indexObject

GET /ads GET /ads.xml



8
9
10
11
12
13
14
15
16
# File 'app/controllers/ads_controller.rb', line 8

def index
  @search = Ad.search(params[:search])
  @search.meta_sort ||= 'created_at.desc'    
  @ads = @search.page(params[:page]).per(15)

  respond_to do |format|
    format.html
  end
end

#newObject

GET /ads/new



29
30
31
# File 'app/controllers/ads_controller.rb', line 29

def new
  @ad = Ad.new
end

#showObject

GET /ads/1 GET /ads/1.xml



20
21
22
23
24
25
26
# File 'app/controllers/ads_controller.rb', line 20

def show
  @ad = Ad.find(params[:id])

  respond_to do |format|
    format.html 
  end
end

#updateObject

PUT /ads/1 PUT /ads/1.xml



55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/ads_controller.rb', line 55

def update
  @ad = Ad.find(params[:id])

  respond_to do |format|
    if @ad.update_attributes(params[:ad])
      flash[:notice] = :ad_was_successfully_updated.l
      format.html { redirect_to ad_url(@ad) }
    else
      format.html { render :action => "edit" }
    end
  end
end