Class: Junebug::Controllers::Show

Inherits:
R
  • Object
show all
Defined in:
lib/junebug/controllers.rb

Instance Method Summary collapse

Instance Method Details

#get(page_name, version = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/junebug/controllers.rb', line 17

def get page_name, version = nil
  @page = Page.find_by_title(page_name.gsub(/_/,' '))
  if @page.nil?
    logged_in? ? redirect(Edit, page_name, 1) : redirect("/login?return_to=#{CGI::escape('/'+page_name)}")
  else
    @page_title = @page.title
    @version = (version.nil? or version == @page.version.to_s) ? @page : @page.versions.find_by_version(version)
    render :show
  end
end