我使用Ember作为我的webapp,我有这段代码:
{{#if canAcceptPayPal}}
}),
但这只返回一个promise而不是boolean值。我在车把中使用它:
canAcceptPayPal: computed('data.event.paymentCurrency', function() {
this.get('store').queryRecord('setting', {})
.then(setting => {
this.set('canAcceptPayPal', (setting.paypalSandboxUsername || setting.paypalLiveUsername) && find(paymentCurrencies, ['code', this.get('data.event.paymentCurrency')]).paypal);
this.rerender();
});
我在这里缺少什么?
解决方案
正如Amandan指出的那样,在当时的调用中重新渲染起作用了:
class Booking < ApplicationRecord
belongs_to :course , :optional => true
belongs_to :event, :optional => true
serialize :notification_params, Hash
def paypal_url(return_path)
values = {
business: "merchant@gmail.com",
cmd: "_xclick",
upload: 1,
return: "#{Rails.application.secrets.app_host}#{return_path}",
invoice: id,
amount: course.course_fee,
item_name: course.title,
item_number: course.id,
quantity: '1',
notify_url: "#{Rails.application.secrets.app_host}/hook"
}
"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?" +
values.to_query
end
end
}),