app/controllers/admin/posts_controller.rb in tb_blog-1.1.2 vs app/controllers/admin/posts_controller.rb in tb_blog-1.1.3
- old
+ new
@@ -9,32 +9,32 @@
@posts = SpudPost.where(:is_news => false).order('published_at desc').includes(:pending_comments, :author).paginate(:page => params[:page], :per_page => 15)
respond_with @posts
end
def edit
- @categories = SpudPostCategory.grouped
+ @categories = SpudPostCategory.ordered
respond_with @post
end
def update
- @categories = SpudPostCategory.grouped
+ @categories = SpudPostCategory.ordered
params[:spud_post][:spud_site_ids] ||= []
params[:spud_post][:updated_at] = Time.now()
if @post.update_attributes(post_params)
flash[:notice] = 'Post was successfully updated.'
end
respond_with @post, :location => admin_posts_path
end
def new
- @categories = SpudPostCategory.grouped
+ @categories = SpudPostCategory.ordered
@post = SpudPost.new(:published_at => Time.zone.now, :spud_user_id => current_user.id, :spud_site_ids => [session[:admin_site] || 0])
respond_with @post
end
def create
- @categories = SpudPostCategory.grouped
+ @categories = SpudPostCategory.ordered
params[:spud_post][:spud_site_ids] ||= []
@post = SpudPost.new(post_params)
if @post.save
flash[:notice] = 'Post was successfully created.'
end
@@ -57,9 +57,13 @@
redirect_to admin_posts_path and return false
end
end
def post_params
- params.require(:spud_post).permit(:published_at, :title, :content, :spud_user_id, :url_name, :visible, :comments_enabled, :meta_keywords, :meta_description, :content_format, :category_ids => [], :spud_site_ids => [])
+ permitted = [:published_at, :title, :content, :spud_user_id, :url_name, :visible, :comments_enabled, :meta_keywords, :meta_description, :content_format, :category_ids => [], :spud_site_ids => []]
+ if Spud::Blog.permitted_attributes.present?
+ permitted = permitted + Spud::Blog.permitted_attributes
+ end
+ params.require(:spud_post).permit(permitted)
end
end