Class: Spud::Admin::NewsPostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Spud::Admin::NewsPostsController
- Defined in:
- app/controllers/spud/admin/news_posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/spud/admin/news_posts_controller.rb', line 34 def create @categories = SpudPostCategory.grouped params[:spud_post][:spud_site_ids] ||= [] @post = SpudPost.new(post_params) if @post.save flash[:notice] = 'News Post was successfully created.' end respond_with @post, :location => spud_admin_news_posts_path end |
#destroy ⇒ Object
44 45 46 47 48 49 |
# File 'app/controllers/spud/admin/news_posts_controller.rb', line 44 def destroy if @post.destroy flash[:notice] = 'News Post was successfully deleted.' end respond_with @post, :location => spud_admin_news_posts_path end |
#edit ⇒ Object
14 15 16 17 |
# File 'app/controllers/spud/admin/news_posts_controller.rb', line 14 def edit @categories = SpudPostCategory.grouped respond_with @post end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/spud/admin/news_posts_controller.rb', line 9 def index @posts = SpudPost.where(:is_news => true).order('published_at desc').includes(:comments).paginate(:page => params[:page], :per_page => 15) respond_with @posts end |
#new ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/spud/admin/news_posts_controller.rb', line 28 def new @categories = SpudPostCategory.grouped @post = SpudPost.new(:published_at => Time.zone.now, :spud_user_id => current_user.id, :is_news => true, :comments_enabled => false, :spud_site_ids => [current_site_id]) respond_with @post end |
#update ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/spud/admin/news_posts_controller.rb', line 19 def update @categories = SpudPostCategory.grouped params[:spud_post][:spud_site_ids] ||= [] if @post.update_attributes(post_params) flash[:notice] = 'News Post was successfully updated.' end respond_with @post, :location => spud_admin_news_posts_path end |