diff options
author | Joe Sak <joe@joesak.com> | 2011-07-12 16:39:33 -0500 |
---|---|---|
committer | Joe Sak <joe@joesak.com> | 2011-07-12 16:39:33 -0500 |
commit | c82a32ed3e3cc45e3425ae360b8a537a6ad367a1 (patch) | |
tree | 6daba14d6a69249836717f71d12035ecee0aa32c /app | |
parent | 8aad45e5b04121a63760edec98fb2205a9111b48 (diff) | |
download | refinerycms-blog-c82a32ed3e3cc45e3425ae360b8a537a6ad367a1.tar.gz refinerycms-blog-c82a32ed3e3cc45e3425ae360b8a537a6ad367a1.tar.bz2 refinerycms-blog-c82a32ed3e3cc45e3425ae360b8a537a6ad367a1.zip |
this is the 'railscasts' way of handling the category checkboxes
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/blog/posts_controller.rb | 7 | ||||
-rw-r--r-- | app/views/admin/blog/posts/_form.html.erb | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/admin/blog/posts_controller.rb b/app/controllers/admin/blog/posts_controller.rb index dbf13b2..2b124ba 100644 --- a/app/controllers/admin/blog/posts_controller.rb +++ b/app/controllers/admin/blog/posts_controller.rb @@ -1,7 +1,8 @@ module Admin module Blog class PostsController < Admin::BaseController - + before_filter :check_category_ids, :only => :update + crudify :blog_post, :title_attribute => :title, :order => 'published_at DESC' @@ -85,6 +86,10 @@ module Admin def find_all_categories @blog_categories = BlogCategory.find(:all) end + + def check_category_ids + params[:blog_post][:category_ids] ||= [] + end end end end
\ No newline at end of file diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb index ffb790d..c891b63 100644 --- a/app/views/admin/blog/posts/_form.html.erb +++ b/app/views/admin/blog/posts/_form.html.erb @@ -70,8 +70,6 @@ <ul class='blog_categories'> <% @blog_categories.each do |category| %> <li> - <%= hidden_field_tag 'blog_post[category_ids][]', category.id, - :value => 0 %> <%= check_box_tag 'blog_post[category_ids][]', category.id, @blog_post.categories.include?(category), :id => (id="blog_post_category_ids_#{category.id}") %> |