Class: HelpAnywhere::PagesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/help_anywhere/pages_controller.rb', line 2

def create
  page = HelpAnywhere::Page.new
  page.resource = HelpAnywhere::Resource.find_by_id params[:resource_id]

  if page.save
    render :json => {
      :id => page.id,
      :order => page.number
    }
  else
    render :json => { :status => "BAD", :errors => page.errors }
  end
end

#showObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/help_anywhere/pages_controller.rb', line 16

def show
  page = HelpAnywhere::Page.find_by_id params[:page_id]

  if resource.nil?
    render :json => nil
  else
    render :json => {
      :id => page.id,
      :order => page.number,
      :items => page.items
    }
  end
end