Class: PagesController

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

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #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

#cache_action?Boolean


9
10
11
# File 'app/controllers/pages_controller.rb', line 9

def cache_action?
  !logged_in? && controller_name.eql?('pages')
end

#createObject


44
45
46
47
48
49
50
51
52
# File 'app/controllers/pages_controller.rb', line 44

def create
  @page = Page.new(page_params)
  if @page.save
    flash[:notice] = :page_was_successfully_created.l
    redirect_to admin_pages_path
  else
    render :action => :new
  end
end

#destroyObject


63
64
65
66
67
# File 'app/controllers/pages_controller.rb', line 63

def destroy
  @page.destroy
  flash[:notice] = :page_was_successfully_deleted.l
  redirect_to admin_pages_path
end

#editObject


40
41
42
# File 'app/controllers/pages_controller.rb', line 40

def edit
  @page = Page.unscoped.find(params[:id])
end

#indexObject


16
17
18
# File 'app/controllers/pages_controller.rb', line 16

def index
  @pages = Page.unscoped.order('created_at DESC').page(params[:page])
end

#newObject


36
37
38
# File 'app/controllers/pages_controller.rb', line 36

def new
  @page = Page.new
end

#previewObject


20
21
22
23
# File 'app/controllers/pages_controller.rb', line 20

def preview
  @page = Page.unscoped.find(params[:id])
  render :action => :show
end

#showObject


25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/pages_controller.rb', line 25

def show
  @page = Page.live.find(params[:id])
  unless logged_in? || @page.page_public
    flash[:error] = :page_not_public_warning.l
    redirect_to :controller => 'sessions', :action => 'new'
  end
rescue
  flash[:error] = :page_not_found.l
  redirect_to home_path
end

#updateObject


54
55
56
57
58
59
60
61
# File 'app/controllers/pages_controller.rb', line 54

def update
  if @page.update_attributes(page_params)
    flash[:notice] = :page_was_successfully_updated.l
    redirect_to admin_pages_path
  else
    render :action => :edit
  end
end