我如何使用javascript中的Rails.logger

use*_*592 0 javascript jquery-ui ruby-on-rails-3

我nside一个html.erb,我想使用记录器

<script type="text/javascript">
  $j(function(){

    $j('#AddQuestion').click(function(){
     //Send and http transaction to the server to get the address
      $j('#dialog').dialog(
        {buttons:{OK:function (event) {
                say('You clicked the ' + $(event.target).text() + ' button' );
              },  No:function (event) {
                say('You clicked the ' + $(event.target).text() + ' button' );
              }
                }
         });

      $j('#dialog').dialog('open');

    });
  });
</script>
Run Code Online (Sandbox Code Playgroud)

scr*_*agz 8

# controllers/logs_controller.rb
class LogsController < ApplicationController
  def create
    logger.debug params['message']
    render :nothing => true
  end
end

# config/routes.rb
map.logs "logs", :controller => 'logs', :action => 'create', :conditions => {:method => :post}

# js
$.post('/logs', {message: 'Your log message'})
Run Code Online (Sandbox Code Playgroud)