weixin_33695450 2017-11-04 09:39 采纳率: 0%
浏览 4

从JS请求到Rails

I have button with link. = link_to 'Preview', mail_templates_preview_path(mailer: @mail_template.mailer, name: @mail_template.name), id: 'some_id' But i want add params when this button clicked. For this, i try

event.preventDefault();
$.ajax({
  url: this.href,
  type: 'GET',
  data: { template_code: $('#ckeditor').val() },
});

And after i expect what rails redirect me to this.href and render new page(../some_method.html.slim).

MyController
  def some_method
    @mail_template = do_something

  end
end

How i can to do request from js to rails controller and render this controller's page?

  • 写回答

0条回答 默认 最新

    报告相同问题?