当我尝试在我的 Rails 4.1.8 应用程序中使用 Payola/Stripe(自定义表单)付款时,出现错误 500(内部服务器错误)
I get error 500 (Internal Server Error) when I try to pay with Payola/Stripe (Custom Form) in my Rails 4.1.8 application
我需要一些帮助。我正在处理 "Rails Paid Job Board",但我收到错误消息:每当我在我的开发门户上单击 "PAY" 以使用 Payola(Stripe) 自定义表单找到工作 post 时,我都会收到错误消息。
够死的我真不知道该拿什么来解决
请参阅Chrome 浏览器控制台错误转储
Jobs_Controller.rb
class JobsController < ApplicationController
def index
@jobs = Job.paid_ad
end
def show
@job = Job.find(params[:id])
end
def edit
@job = Job.find(params[:id])
redirect_to @job if @job.paid?
end
def update
@job = Job.find(params[:id])
if !(@job.paid?)
@job.update_attributes(stripeEmail: params[:stripeEmail],
payola_sale_guid: params[:payola_sale_guid]
)
# The "has_key?" Returns true if the given key/attribute is present in hash e.g.
# h = { "a" => 100, "b" => 200 }
# h.has_key?("a") #=> true
# h.has_key?("z") #=> false.
# So this means --Update job_params if the given key/attribute is present or not in job.
@job.update(job_params) if params.has_key?(:job)
redirect_to preview_job_path(@job)
else
render :edit
end
end
def new
@job = Job.new
end
def create
@job = Job.new(job_params)
if @job.save
redirect_to preview_job_path(@job)
else
render :new
end
end
def preview
@job = Job.find(params[:id])
redirect_to @job if @job.paid?
end
def payment
@job = Job.find_by_permalink(params[:permalink])
redirect_to job_path(@job) if @job.paid?
end
def search
@jobs = Job.search(params)
end
private
def job_params
params.require(:job).permit(:title, :category, :location, :description, :to_apply, :email, :company_name, :website)
end
end
型号job.rb
class Job < ActiveRecord::Base
include Payola::Sellable
validates :title,
:category,
:location,
:description,
:company_name,
:website,
:email,
:to_apply,
presence: true
validates :title, length: { maximum: 75 }
validates :description, length: { minimum: 300 }
validates :to_apply, length: { maximum: 500 }
validates_formatting_of :email, using: :email
validates_formatting_of :website, using: :url
before_validation :provide_name, :provide_permalink
def self.paid_ad
where.not('stripeEmail' => nil).where.not('payola_sale_guid' => nil).where('created_at > ?', 30.days.ago)
end
def paid?
(!(self.stripeEmail == nil) && !(self.payola_sale_guid == nil))
end
def self.search(params)
jobs = Job.where('name like ? or description like?', "%#{params[:search]}%', '%#{params[:search]}%" ) if params [:search]
jobs
end
private
def provide_name
self.name = 'FarFlung' if self.name == nil
end
def provide_permalink
self.permalink = "#{ self.name } #{ SecureRandom.hex }".parameterize if self.permalink == nil
end
end
查看付款
<div class="container">
<div class="row">
<div class='col-md-4'></div>
<div class="col-md-4 panel panel-default">
<%= render 'shared/two_breaks' %>
<%= simple_form_for(@job, html: { class: 'payola-payment-form',
'data-payola-base-path' => main_app.payola_path,
'data-payola-product' => @job.product_class,
'data-payola-permalink' => @job.permalink }) do |f| %>
<p style="color:red"><span class="payola-payment-error"></span></p>
<div class="form-row">
<div class="col-lg-12 form-group required">
<label class='control-label'>Your email address</label>
<input class='form-control require-validation' type="email" name="stripeEmail" data-payola="email" value="<%= @job.email %>" >
</div>
</div>
<div class='form-row'>
<div class="col-lg-12 form-group card required">
<label class="control-label">Card number</label>
<input autocomplete='off' class='form-control card-number' type="text" data-stripe="number"/>
</div>
</div>
<div class='form-row'>
<div class='col-xs-4 form-group expiration required'>
<label class='control-label'>Month</label>
<input class='form-control' placeholder='MM' type="text" data-stripe="exp_month"/>
</div>
<div class='col-xs-4 form-group expiration required'>
<label class='control-label' >Year</label>
<input class='form-control' placeholder='YYYY' type="text" data-stripe="exp_year"/>
</div>
<div class='col-xs-4 form-group cvc required'>
<label class='control-label'>CVC</label>
<input autocomplete='off' class='form-control' placeholder='ex. 311' type="text" data-stripe="cvc"/>
</div>
</div>
<div class='form-row'>
<div class='col-xs-12'>
<div class='form-control total btn btn-info'>
Total:
<span class='amount'>#3000</span>
</div>
</div>
</div>
<div class='form-row'>
<div class="col-md-12 form-group">
<%= f.submit 'PAY AND DISPLAY AD NOW', class: 'form-control btn btn-primary submit-button' %>
</div>
</div>
<% end %>
<p class="text-center"><%= link_to (image_tag('big.png')) %></p>
<%= render 'shared/two_breaks' %>
</div>
</div>
</div>
Route.rb
Rails.application.routes.draw do
mount Payola::Engine => '/payola', as: :payola
mount RedactorRails::Engine => '/redactor_rails'
root 'jobs#index'
get 'new' => 'jobs#new', as: :new
get 'jobs/:id/preview' => 'jobs#preview', as: :preview_job
get 'payments/:permalink' => 'jobs#payment', as: :buy_ad
get 'jobs/:id/' => 'jobs#show', as: :show_job
post 'payments/:permalink' => 'payola/transactions#create'
resources :jobs, except: :destroy do
collection do
get :search
end
end
end
开发服务器日志
Started POST "/payola/buy/job/farflung-f9418cfd37de67f5bd733b3d2ea39188" for 127.0.0.1 at 2016-04-16 13:25:55 +0100
Processing by Payola::TransactionsController#create as */*
Parameters: {"stripeToken"=>"tok_180sWbCc1zXXaitaIc1ThbwS", "stripeEmail"=>"blaze@gmail.com", "authenticity_token"=>"5cocM2IsdmhayVDyQVPV7/LGh7LyWpFseu+/g1HjW9A=", "product_class"=
>"job", "permalink"=>"farflung-f9418cfd37de67f5bd733b3d2ea39188"}
Payola::Affiliate Load (0.0ms) SELECT "payola_affiliates".* FROM "payola_affiliates" WHERE (lower(code) = lower(NULL)) ORDER BY "payola_affiliates"."id" ASC LIMIT 1
Job Load (1.0ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."permalink" = 'farflung-f9418cfd37de67f5bd733b3d2ea39188' LIMIT 1
Payola::Coupon Load (1.0ms) SELECT "payola_coupons".* FROM "payola_coupons" WHERE (lower(code) = lower(NULL)) ORDER BY "payola_coupons"."id" ASC LIMIT 1
(0.0ms) begin transaction
Payola::Sale Exists (0.0ms) SELECT 1 AS one FROM "payola_sales" WHERE "payola_sales"."guid" IS NULL LIMIT 1
CACHE (0.0ms) SELECT 1 AS one FROM "payola_sales" WHERE "payola_sales"."guid" IS NULL LIMIT 1
Payola::Sale Exists (0.0ms) SELECT 1 AS one FROM "payola_sales" WHERE "payola_sales"."guid" = '16j79c' LIMIT 1
SQL (1.0ms) INSERT INTO "payola_sales" ("amount", "created_at", "currency", "email", "guid", "product_id", "product_type", "state", "stripe_token", "updated_at") VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?, ?) [["amount", 20000], ["created_at", "2016-04-16 12:25:56.073909"], ["currency", "usd"], ["email", "blaze@gmail.com"], ["guid", "16j79c"], ["product_id", 6], ["pr
oduct_type", "Job"], ["state", "pending"], ["stripe_token", "tok_180sWbCc1zXXaitaIc1ThbwS"], ["updated_at", "2016-04-16 12:25:56.073909"]]
SQL (0.0ms) INSERT INTO "versions" ("created_at", "event", "item_id", "item_type") VALUES (?, ?, ?, ?) [["created_at", "2016-04-16 12:25:56.073909"], ["event", "create"], ["item_
id", 8], ["item_type", "Payola::Sale"]]
(163.7ms) commit transaction
Completed 500 Internal Server Error in 539ms
我真的不知道如何解决这个问题。是 Stripe.js 问题,还是我编译的 [jquery.self.js?body=1:9632] 错误图片 posted?
请提供帮助,我们将不胜感激。
注意:正如“Payola-Payments的创建者”所指出的那样,
我收到这个错误是因为:
我的浏览器控制台指示我的服务器正在转储错误,如 HTML 并且 JS 正在尝试将其解析为 JSON。
通过在浏览器的网络选项卡上调查 POST 的结果,我们发现它是 Payola::TransactionsController#create 中的 RuntimeError 说的事实:
No eligible background worker systems found.
解决这个问题
I need to set up a background worker system. https://github.com/peterkeen/payola/wiki/Configuration-options#background-jobs
我相信如果 Background Worker set/configured 正确,这应该可以正常工作。
我需要一些帮助。我正在处理 "Rails Paid Job Board",但我收到错误消息:每当我在我的开发门户上单击 "PAY" 以使用 Payola(Stripe) 自定义表单找到工作 post 时,我都会收到错误消息。
够死的我真不知道该拿什么来解决
请参阅Chrome 浏览器控制台错误转储
Jobs_Controller.rb
class JobsController < ApplicationController
def index
@jobs = Job.paid_ad
end
def show
@job = Job.find(params[:id])
end
def edit
@job = Job.find(params[:id])
redirect_to @job if @job.paid?
end
def update
@job = Job.find(params[:id])
if !(@job.paid?)
@job.update_attributes(stripeEmail: params[:stripeEmail],
payola_sale_guid: params[:payola_sale_guid]
)
# The "has_key?" Returns true if the given key/attribute is present in hash e.g.
# h = { "a" => 100, "b" => 200 }
# h.has_key?("a") #=> true
# h.has_key?("z") #=> false.
# So this means --Update job_params if the given key/attribute is present or not in job.
@job.update(job_params) if params.has_key?(:job)
redirect_to preview_job_path(@job)
else
render :edit
end
end
def new
@job = Job.new
end
def create
@job = Job.new(job_params)
if @job.save
redirect_to preview_job_path(@job)
else
render :new
end
end
def preview
@job = Job.find(params[:id])
redirect_to @job if @job.paid?
end
def payment
@job = Job.find_by_permalink(params[:permalink])
redirect_to job_path(@job) if @job.paid?
end
def search
@jobs = Job.search(params)
end
private
def job_params
params.require(:job).permit(:title, :category, :location, :description, :to_apply, :email, :company_name, :website)
end
end
型号job.rb
class Job < ActiveRecord::Base
include Payola::Sellable
validates :title,
:category,
:location,
:description,
:company_name,
:website,
:email,
:to_apply,
presence: true
validates :title, length: { maximum: 75 }
validates :description, length: { minimum: 300 }
validates :to_apply, length: { maximum: 500 }
validates_formatting_of :email, using: :email
validates_formatting_of :website, using: :url
before_validation :provide_name, :provide_permalink
def self.paid_ad
where.not('stripeEmail' => nil).where.not('payola_sale_guid' => nil).where('created_at > ?', 30.days.ago)
end
def paid?
(!(self.stripeEmail == nil) && !(self.payola_sale_guid == nil))
end
def self.search(params)
jobs = Job.where('name like ? or description like?', "%#{params[:search]}%', '%#{params[:search]}%" ) if params [:search]
jobs
end
private
def provide_name
self.name = 'FarFlung' if self.name == nil
end
def provide_permalink
self.permalink = "#{ self.name } #{ SecureRandom.hex }".parameterize if self.permalink == nil
end
end
查看付款
<div class="container">
<div class="row">
<div class='col-md-4'></div>
<div class="col-md-4 panel panel-default">
<%= render 'shared/two_breaks' %>
<%= simple_form_for(@job, html: { class: 'payola-payment-form',
'data-payola-base-path' => main_app.payola_path,
'data-payola-product' => @job.product_class,
'data-payola-permalink' => @job.permalink }) do |f| %>
<p style="color:red"><span class="payola-payment-error"></span></p>
<div class="form-row">
<div class="col-lg-12 form-group required">
<label class='control-label'>Your email address</label>
<input class='form-control require-validation' type="email" name="stripeEmail" data-payola="email" value="<%= @job.email %>" >
</div>
</div>
<div class='form-row'>
<div class="col-lg-12 form-group card required">
<label class="control-label">Card number</label>
<input autocomplete='off' class='form-control card-number' type="text" data-stripe="number"/>
</div>
</div>
<div class='form-row'>
<div class='col-xs-4 form-group expiration required'>
<label class='control-label'>Month</label>
<input class='form-control' placeholder='MM' type="text" data-stripe="exp_month"/>
</div>
<div class='col-xs-4 form-group expiration required'>
<label class='control-label' >Year</label>
<input class='form-control' placeholder='YYYY' type="text" data-stripe="exp_year"/>
</div>
<div class='col-xs-4 form-group cvc required'>
<label class='control-label'>CVC</label>
<input autocomplete='off' class='form-control' placeholder='ex. 311' type="text" data-stripe="cvc"/>
</div>
</div>
<div class='form-row'>
<div class='col-xs-12'>
<div class='form-control total btn btn-info'>
Total:
<span class='amount'>#3000</span>
</div>
</div>
</div>
<div class='form-row'>
<div class="col-md-12 form-group">
<%= f.submit 'PAY AND DISPLAY AD NOW', class: 'form-control btn btn-primary submit-button' %>
</div>
</div>
<% end %>
<p class="text-center"><%= link_to (image_tag('big.png')) %></p>
<%= render 'shared/two_breaks' %>
</div>
</div>
</div>
Route.rb
Rails.application.routes.draw do
mount Payola::Engine => '/payola', as: :payola
mount RedactorRails::Engine => '/redactor_rails'
root 'jobs#index'
get 'new' => 'jobs#new', as: :new
get 'jobs/:id/preview' => 'jobs#preview', as: :preview_job
get 'payments/:permalink' => 'jobs#payment', as: :buy_ad
get 'jobs/:id/' => 'jobs#show', as: :show_job
post 'payments/:permalink' => 'payola/transactions#create'
resources :jobs, except: :destroy do
collection do
get :search
end
end
end
开发服务器日志
Started POST "/payola/buy/job/farflung-f9418cfd37de67f5bd733b3d2ea39188" for 127.0.0.1 at 2016-04-16 13:25:55 +0100
Processing by Payola::TransactionsController#create as */*
Parameters: {"stripeToken"=>"tok_180sWbCc1zXXaitaIc1ThbwS", "stripeEmail"=>"blaze@gmail.com", "authenticity_token"=>"5cocM2IsdmhayVDyQVPV7/LGh7LyWpFseu+/g1HjW9A=", "product_class"=
>"job", "permalink"=>"farflung-f9418cfd37de67f5bd733b3d2ea39188"}
Payola::Affiliate Load (0.0ms) SELECT "payola_affiliates".* FROM "payola_affiliates" WHERE (lower(code) = lower(NULL)) ORDER BY "payola_affiliates"."id" ASC LIMIT 1
Job Load (1.0ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."permalink" = 'farflung-f9418cfd37de67f5bd733b3d2ea39188' LIMIT 1
Payola::Coupon Load (1.0ms) SELECT "payola_coupons".* FROM "payola_coupons" WHERE (lower(code) = lower(NULL)) ORDER BY "payola_coupons"."id" ASC LIMIT 1
(0.0ms) begin transaction
Payola::Sale Exists (0.0ms) SELECT 1 AS one FROM "payola_sales" WHERE "payola_sales"."guid" IS NULL LIMIT 1
CACHE (0.0ms) SELECT 1 AS one FROM "payola_sales" WHERE "payola_sales"."guid" IS NULL LIMIT 1
Payola::Sale Exists (0.0ms) SELECT 1 AS one FROM "payola_sales" WHERE "payola_sales"."guid" = '16j79c' LIMIT 1
SQL (1.0ms) INSERT INTO "payola_sales" ("amount", "created_at", "currency", "email", "guid", "product_id", "product_type", "state", "stripe_token", "updated_at") VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?, ?) [["amount", 20000], ["created_at", "2016-04-16 12:25:56.073909"], ["currency", "usd"], ["email", "blaze@gmail.com"], ["guid", "16j79c"], ["product_id", 6], ["pr
oduct_type", "Job"], ["state", "pending"], ["stripe_token", "tok_180sWbCc1zXXaitaIc1ThbwS"], ["updated_at", "2016-04-16 12:25:56.073909"]]
SQL (0.0ms) INSERT INTO "versions" ("created_at", "event", "item_id", "item_type") VALUES (?, ?, ?, ?) [["created_at", "2016-04-16 12:25:56.073909"], ["event", "create"], ["item_
id", 8], ["item_type", "Payola::Sale"]]
(163.7ms) commit transaction
Completed 500 Internal Server Error in 539ms
我真的不知道如何解决这个问题。是 Stripe.js 问题,还是我编译的 [jquery.self.js?body=1:9632] 错误图片 posted?
请提供帮助,我们将不胜感激。
注意:正如“Payola-Payments的创建者”所指出的那样,
我收到这个错误是因为:
我的浏览器控制台指示我的服务器正在转储错误,如 HTML 并且 JS 正在尝试将其解析为 JSON。
通过在浏览器的网络选项卡上调查 POST 的结果,我们发现它是 Payola::TransactionsController#create 中的 RuntimeError 说的事实:
No eligible background worker systems found.
解决这个问题
I need to set up a background worker system. https://github.com/peterkeen/payola/wiki/Configuration-options#background-jobs
我相信如果 Background Worker set/configured 正确,这应该可以正常工作。