zu bezahlen Ich werde etwas Hilfe mögen. Ich arbeite an einem "Rails Paid Job Board", und ich bekomme Fehler: "**Completed 500 (Internal Server Error)**"
, wenn ich auf "PAY" für einen Stellenposten mit Payola (Stripe) Custom Form auf meinem Entwicklungsportal klicke.Ich erhalte den Fehler 500 (Interner Serverfehler), wenn ich versuche, Payola/Stripe (benutzerdefiniertes Formular) in meiner Rails 4.1.8 Anwendung
Es ist genug töten Ich weiß wirklich nicht, was ich angehen soll, um es zu lösen.
freundlicher Chrome Browser-Konsole Fehler
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
Modell 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
Dump sehen
Ansicht für Zahlungen
<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
Development Server log
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"=>"[email protected]", "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", "[email protected]"], ["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
Ich weiß wirklich nicht, wie man dieses Problem angehen . Ist es stripe.js Problem oder mein kompilierter [jquery.self.js? Body = 1: 9632] wie auf dem Fehlerbild gepostet?
Bitte, und Hilfe wird geschätzt.
Wahrscheinlich habe ich mein Background Worker System nicht richtig eingestellt/konfiguriert. Ich bekomme Fehler: 'Redis :: CannotConnectError in Payola :: TransactionsController # create' ' Fehler beim Verbinden mit Redis auf 127.0.0.1: 6379 (Redis :: TimeoutError) ' Kann mich jemand diesen Fehler beheben? –
Was ich getan habe, um das ganze Problem nach dieser Lösung zu beheben, war dieser Link: http://stackoverflow.com/questions/36864733/i-get-a-pending-error- whenever-i-click-on- pay-using-payola-zahlung-gem-a-gem Ich habe meine Hintergrund Worker und immer noch dieses Problem in den Link, und ich löste es mit der akzeptierten Antwort aus dem Link gebucht. –