Class: AdsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- AdsController
- Defined in:
- app/controllers/ads_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /ads POST /ads.xml.
-
#destroy ⇒ Object
DELETE /ads/1 DELETE /ads/1.xml.
-
#edit ⇒ Object
GET /ads/1;edit.
-
#index ⇒ Object
GET /ads GET /ads.xml.
-
#new ⇒ Object
GET /ads/new.
-
#show ⇒ Object
GET /ads/1 GET /ads/1.xml.
-
#update ⇒ Object
PUT /ads/1 PUT /ads/1.xml.
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
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
GET /ads/1;edit
34 35 36 |
# File 'app/controllers/ads_controller.rb', line 34 def edit @ad = Ad.find(params[:id]) end |
#index ⇒ Object
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. ||= 'created_at.desc' @ads = @search.page(params[:page]).per(15) respond_to do |format| format.html end end |
#new ⇒ Object
GET /ads/new
29 30 31 |
# File 'app/controllers/ads_controller.rb', line 29 def new @ad = Ad.new end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |