小编kar*_*uke的帖子

在Rails中录制音频

在我正在开发的应用程序上,我想要一种可靠的方式来录制音频并将其上传到S3。我真的看不到任何好的解决方案。希望我能提供一些帮助。我最初是在考虑使用getUserMedia()Javascript API,但在Safari上不起作用。

ruby-on-rails voice-recording ruby-on-rails-4

5
推荐指数
0
解决办法
1249
查看次数

`update`上的`after_commit`回调不会触发

我已经定义了after_commit回调update.它不会在rspec中触发.

这是我的回调:

after_commit :notify_trip, :if => Proc.new { |trip| trip.can_send_schedule_notification? }, on: :update
Run Code Online (Sandbox Code Playgroud)

这是我的rspec代码:

@work_order.update_attributes(:status_id => statuses(:scheduled).id, :tour_id => @tour.id)
@work_order.run_callbacks(:commit)
assert_equal 1, ActionMailer::Base.deliveries.size
expect(ActionMailer::Base.deliveries[0].to).to include(@user.email)
expect(ActionMailer::Base.deliveries[0].subject).to include("Your trip has been scheduled!")
Run Code Online (Sandbox Code Playgroud)

这里回调不是调用和ActionMailer::Base.deliveries.size返回0

对此有什么建议吗?

rspec ruby-on-rails

5
推荐指数
2
解决办法
2506
查看次数

由于重定向,设计 JSON API 返回 200 而不是 401

我在 Rails API 上运行 Angular。对于身份验证,我正在拦截 401 状态:

.config(['$httpProvider', function($httpProvider){
    // Prevent rails from making new sessions each time
    $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');

    var interceptor = ['$location', '$rootScope', '$q', function($location, $rootScope, $q) {
      function success(response) {
        return response;
      }

      function error(response) {
        if (response.status === 401) {
          $rootScope.$broadcast('event:unauthorized');
          $location.path('/login');
          return response;
        }
        return $q.reject(response);
      }

      return function(promise) {
        return promise.then(success, error);
      };
    }];
    $httpProvider.responseInterceptors.push(interceptor);
  }])
Run Code Online (Sandbox Code Playgroud)

但是拦截器没有触发,因为重定向显示状态为 200

Started GET "/api/v1/stages" for 127.0.0.1 at 2014-02-23 04:38:12 +0530
Processing by StagesController#index as HTML
Completed …
Run Code Online (Sandbox Code Playgroud)

json ruby-on-rails devise angularjs

3
推荐指数
1
解决办法
2711
查看次数

Facebook Ads Insights API 的 date_start 和 date_stop 是在哪个时区发送的?

Facebook 的 Ads Insights API 返回date_startdate_stop但由于它们是日期对象,我无法确定使用哪个时区来划分日期。是使用 Facebook 的 API 时区,他们提到是 PT (UTC -8) 还是根据 AdAccount 的时区,因为我在 Ads Insights API 文档中发现提到了帐户的时区。

facebook facebook-graph-api facebook-ads-api facebook-marketing-api

1
推荐指数
1
解决办法
2990
查看次数