gpt4 book ai didi

javascript - 如何使用 javascript 中的 Rails.logger

转载 作者:行者123 更新时间:2023-11-28 11:19:24 26 4
gpt4 key购买 nike

我在 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>

最佳答案

# 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'})

关于javascript - 如何使用 javascript 中的 Rails.logger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4730319/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com