0
좋아요를하고있다 만들기, 내가 작업이 커피 스크립트UJS는 액션이 게시물
#create.js.coffee
$("#discussion_posts_table").append("<%= escape_javascript(render(@post)) %>");
$("#post_body").val("");
하는 경우를 발로 차는 다음과 같은 형식
#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 %>
벗기
#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
를 만들 다음 한 나는 폼에서 :remote => true
을 가져 간다. 모든 것이 잘 작동하지만, 두 개의 모델 객체 인 instea를 만든다. d 개 중 하나.
내가 여기서 잘못 할 수있는 아이디어가 있습니까?
'# create.js.coffee'? 확실합니까? '# create.js.erb'가 아닌가요? –
예. Erb는 확장 프로그램에 없지만 여전히 이벤트를 평가합니다. 이 스레드의 너무 떨어져 기반으로 http://stackoverflow.com/questions/11007498/rails-coffeescript-and-erb/11007588 – DVG