Class: Bolt::ArticlesController
Instance Method Summary
collapse
#blank
#bolt_config_dashboard_url, #bolt_config_email_from_address, #bolt_config_hostname, #bolt_config_javascript_includes, #bolt_config_logo, #bolt_config_stylesheet_includes, #bolt_config_website_name
Methods included from BoltHelper
#bolt_check_box, #bolt_check_box_group, #bolt_collection_select, #bolt_date_select, #bolt_datetime_select, #bolt_file_field, #bolt_generate_page_title, #bolt_get_access_level_array, #bolt_get_access_level_text, #bolt_get_full_version_string, #bolt_get_short_version_string, #bolt_get_version_info, #bolt_hidden_field, #bolt_password_field, #bolt_radio_button, #bolt_radio_button_group, #bolt_select, #bolt_show_icon, #bolt_show_row_icon, #bolt_table_cell_link, #bolt_table_cell_no_link, #bolt_text_area, #bolt_text_area_big, #bolt_text_field, #bolt_time_select, #bolt_time_zone_select
Instance Method Details
#create ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/controllers/bolt/articles_controller.rb', line 45
def create
@article = Article.new params[:article]
if @article.save
flash[:notice] = 'Article created'
redirect_to bolt_articles_path
else
@categories =Category.all
@statuses = Status.all
@accesses = Access.all
flash.now[:warning] = 'There were problems when trying to create a new article'
render :action => :new
end
end
|
#destroy ⇒ Object
74
75
76
77
78
79
80
|
# File 'app/controllers/bolt/articles_controller.rb', line 74
def destroy
@article = Article.find params[:id]
@article.destroy
flash[:notice] = 'Article has been deleted'
redirect_to bolt_articles_path
end
|
#destroy_multiple ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/bolt/articles_controller.rb', line 82
def destroy_multiple
ids= params[:id]
idarr=ids.split(',')
idarr.each do |del|
@article = Article.find(del)
@article.destroy
end
respond_to do |format|
format.html { redirect_to :back }
end
end
|
#index ⇒ Object
optional filters for defining usage according to Bolt::Users access_levels before_filter :needs_admin, :except => [:action1, :action2] before_filter :needs_admin_or_current_user, :only => [:action1, :action2]
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/bolt/articles_controller.rb', line 10
def index
sortcolumn=(params[:sort]==nil)? ' ' : params[:sort]
@bolt_articles = Article.find(:all, :order => sortcolumn)
@bolt_page_title = 'Articles'
@articles = Article.paginate :page => params[:page]
respond_to do |format|
format.html
format.json { render :json => @bolt_articles }
end
end
|
#new ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/bolt/articles_controller.rb', line 33
def new
@bolt_page_title = 'Add a new article'
@article = Article.new
@categories =Category.all
@statuses = Status.all
@accesses = Access.all
respond_to do |format|
format.html
format.json { render :json => @bolt_articles }
end
end
|
#show ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/bolt/articles_controller.rb', line 22
def show
@bolt_article = Bolt::Article.find(params[:id])
@bolt_page_title = 'View article'
@article = Article.find params[:id]
@categories =Category.all
@statuses = Status.all
@accesses = Access.all
@u_categories = @bolt_article.groups.collect{|g| g.id}
end
|
#update ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/bolt/articles_controller.rb', line 60
def update
@bolt_page_title = 'Update article'
@article = Article.find params[:id]
if @article.update_attributes params[:article]
flash[:notice] = 'Article has been updated'
redirect_to bolt_articles_path
else
flash.now[:warning] = 'There were problems when trying to update this article'
render :action => :show
end
end
|