Class: MetroAreasController

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

Instance Method Summary collapse

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

#createObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/metro_areas_controller.rb', line 26

def create
  @metro_area = MetroArea.new(metro_area_params)
  
  respond_to do |format|
    if @metro_area.save
      flash[:notice] = :metro_area_was_successfully_created.l
      
      format.html { redirect_to metro_area_url(@metro_area) }
      format.xml do
        headers["Location"] = metro_area_url(@metro_area)
        render :nothing => true, :status => "201 Created"
      end
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @metro_area.errors.to_xml }
    end
  end
end

#destroyObject


59
60
61
62
63
64
65
66
67
# File 'app/controllers/metro_areas_controller.rb', line 59

def destroy
  @metro_area = MetroArea.find(params[:id])
  @metro_area.destroy
  
  respond_to do |format|
    format.html { redirect_to metro_areas_url   }
    format.xml  { render :nothing => true }
  end
end

#editObject


22
23
24
# File 'app/controllers/metro_areas_controller.rb', line 22

def edit
  @metro_area = MetroArea.find(params[:id])
end

#indexObject


5
6
7
# File 'app/controllers/metro_areas_controller.rb', line 5

def index
  @metro_areas = MetroArea.includes(:country).order("countries.name, metro_areas.name DESC").references(:countries).page(params[:page])
end

#newObject


18
19
20
# File 'app/controllers/metro_areas_controller.rb', line 18

def new
  @metro_area = MetroArea.new
end

#showObject


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

def show
  @metro_area = MetroArea.find(params[:id])
  
  respond_to do |format|
    format.html 
    format.xml  { render :xml => @metro_area.to_xml }
  end
end

#updateObject


45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/metro_areas_controller.rb', line 45

def update
  @metro_area = MetroArea.find(params[:id])
  
  respond_to do |format|
    if @metro_area.update_attributes(metro_area_params)
      format.html { redirect_to metro_area_url(@metro_area) }
      format.xml  { render :nothing => true }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @metro_area.errors.to_xml }        
    end
  end
end