Class: Admin::PapersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/papers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Create a Paper

Params

  • paper = Hash of Paper’s attributes

The Paper can be a child of another Paper.



33
34
35
36
37
38
39
40
41
# File 'app/controllers/admin/papers_controller.rb', line 33

def create
  if @paper.save
    flash[:notice] = t('paper.create.success').capitalize
    redirect_to([forgeos_blog, :admin, :papers])
  else
    flash[:error] = t('paper.create.failed').capitalize
    render :action => 'new'
  end
end

#destroyObject

Destroy a Paper

Params

  • id = Paper’s id

Output

if destroy succed, return the Categories list


67
68
69
70
71
72
73
74
75
# File 'app/controllers/admin/papers_controller.rb', line 67

def destroy
  #set page_url for cache sweeper
  @paper.paper_url = @paper.paper_urls.dup
  if @paper.destroy
    flash[:notice] = t('paper.destroy.success').capitalize
  else
    flash[:error] = t('paper.destroy.failed').capitalize
  end
end

#editObject

Edit a Paper

Params

  • id = Paper’s id to edit

  • paper = Hash of Paper’s attributes

The Paper can be a child of another Paper.



49
50
# File 'app/controllers/admin/papers_controller.rb', line 49

def edit
end

#indexObject

List Categories



12
13
14
15
16
17
18
19
20
# File 'app/controllers/admin/papers_controller.rb', line 12

def index
  respond_to do |format|
    format.html
    format.json do
      sort
      render :layout => false
    end
  end
end

#newObject



22
23
# File 'app/controllers/admin/papers_controller.rb', line 22

def new
end

#showObject



25
26
# File 'app/controllers/admin/papers_controller.rb', line 25

def show
end

#updateObject



52
53
54
55
56
57
58
59
60
# File 'app/controllers/admin/papers_controller.rb', line 52

def update
  if @paper.update_attributes(params[:paper])
    flash[:notice] = t('paper.update.success').capitalize
    redirect_to([forgeos_blog, :admin, :papers])
  else
    flash[:error] = t('paper.update.failed').capitalize
    render :action => 'edit'
  end
end

#urlObject



7
8
9
# File 'app/controllers/admin/papers_controller.rb', line 7

def url
  render :text => Forgeos::url_generator(params[:url])
end