【发布时间】:2016-01-09 10:55:08
【问题描述】:
在我的网络应用程序中,当我检查 Heroku 上计费页面的 HTML 时 - 表单的 action 属性 为空,但在我的本地计算机上(处于开发和生产模式)它正确指向ENV['TWOCHECKOUT_PURCHASE_URL'] 变量的值。
Form 的action 属性必须包含不同的 URL,具体取决于 Rails 运行的环境。如何让它发挥作用?
application.yml
TWOCHECKOUT_PURCHASE_URL: 'https://sandbox.2checkout.com/checkout/purchase'
home.html.erb
<sb-billing></sb-billing>
sbBillingDirective.js.erb
//= depend_on_asset "billing_directive.html"
(function() {
angular
.module('scrumban.widgets')
.directive('sbBilling', billingDirective);
function billingDirective() {
return {
restrict: 'EA',
scope: {},
replace: true,
templateUrl: '<%= asset_path("billing_directive.html") %>',
controller: BillingController,
controllerAs: 'vm'
}
}
BillingController.$inject = ['$scope', 'BillingService', '_'];
function BillingController($scope, BillingService, _) {
// not relevant code
}
billing_directive.html.erb
<form id="2checkout"
action="<%= ENV['TWOCHECKOUT_PURCHASE_URL'] %>"
method="post">
</form>
【问题讨论】:
标签: angularjs ruby-on-rails-4 heroku environment-variables