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?, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
Methods included from BaseHelper
#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #tiny_mce_init_if_needed, #tiny_mce_js, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget
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
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/ads_controller.rb', line 45 def create @ad = Ad.new(ad_params) 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
75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/ads_controller.rb', line 75 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
39 40 41 |
# File 'app/controllers/ads_controller.rb', line 39 def edit @ad = Ad.find(params[:id]) end |
#index ⇒ Object
GET /ads GET /ads.xml
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/ads_controller.rb', line 12 def index @search = Ad.search(params[:q]) @result = @search.result @ads = @result.order('created_at DESC').distinct @ads = @result.page(params[:page]).per(15) respond_to do |format| format.html end end |
#new ⇒ Object
GET /ads/new
34 35 36 |
# File 'app/controllers/ads_controller.rb', line 34 def new @ad = Ad.new end |
#show ⇒ Object
GET /ads/1 GET /ads/1.xml
25 26 27 28 29 30 31 |
# File 'app/controllers/ads_controller.rb', line 25 def show @ad = Ad.find(params[:id]) respond_to do |format| format.html end end |
#update ⇒ Object
PUT /ads/1 PUT /ads/1.xml
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/ads_controller.rb', line 60 def update @ad = Ad.find(params[:id]) respond_to do |format| if @ad.update_attributes(ad_params) flash[:notice] = :ad_was_successfully_updated.l format.html { redirect_to ad_url(@ad) } else format.html { render :action => "edit" } end end end |