Skip to content

Instantly share code, notes, and snippets.

@colewinans
Last active December 19, 2015 14:39
Show Gist options
  • Save colewinans/5970879 to your computer and use it in GitHub Desktop.
Save colewinans/5970879 to your computer and use it in GitHub Desktop.
# Creates 'x' categorizations with null category_id's
def create
@user = current_user
@post = @user.posts.create(params[:post])
@categories = @user.categories.all
@post.categorizations.build(:category_id => params[:categorization_ids])
params[:categorization_ids].each do |categorization|
@post.categorizations.build(params[:categorization_id])
end
end
# Form and nested form below
= form_for [@user, @post] do |f|
.field
.radio_brick.add_new.upload_image
%a.big_link
%i Q
%h4 Upload Image
%h5
Drag an image here or
%a{:href => "#", :id => "browse_file"}
browse
for an image to upload.
%h4.file_name
= f.file_field :thumbnail_image, :class => 'hidden', :id => "post_upload"
.field
%span Title:
= f.text_field :name
.field
%span Subtitle:
= f.text_field :subtitle
.field
%span Tags:
= f.text_field :tag_list
.field.no_border.summary
%span Summary:
= f.text_area :summary
%ul
= f.fields_for :categorization do |categorization|
- @categories.each do |category|
%li
= check_box_tag 'categorization_ids[]', category.id
= category.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment