Okay, I have the following create action
#posts_controller, nested resource under discussions
def create
@post = Post.new(params[:post])
@post.user = current_user
@post.discussion = Discussion.find(params[:discussion_id])
respond_to do |format|
if @post.save!
format.js
format.html { redirect_to discussion_posts_path(@post.discussion), notice: 'Post was successfully created.' }
else
format.html { render :action => "new" }
end
end
end
which comes off the following form
#index.html.erb#quick_reply
<%= simple_form_for [@discussion, @post], :remote => true do |f| %>
<%= f.input :body, :input_html => {:class => 'span12 short_text_area' } %>
<%= f.submit 'Post Reply', :class => 'btn-primary' %>
<% end %>
Kicking off this coffeescript
#create.js.coffee
$("#discussion_posts_table").append("<%= escape_javascript(render(@post)) %>");
$("#post_body").val("");
If I take :remote => true
out of the form, everything works great, but putting it in makes two model objects instead of one.
Any idea what I could be doing wrong here?
The problem, as it turns out, was that I had precompiled assets in dev, which meant everything was in there twice.