导师中的ActionController :: UrlGenerationError#show

时间:2017-04-01 20:21:22

标签: ruby-on-rails ruby

当我向平台添加新教师时,我会出现此错误,我称之为“Mentor”。

enter image description here

在我做了两件事之前,一切正常:

  • 将条带付款添加到导师资料
  • 添加然后从导师资料中移除了用户友好的id gem,因为它导致我在接下来的步骤中出现问题。

这是我的show.html.erb页面中与条带付款相关的摘录

    <%= form_tag call_path(slug: @mentor.slug) do %>
    <script
      src="https://checkout.stripe.com/checkout.js" class="stripe-button"
      data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
      data-amount="<%= (@mentor.price * 100).floor %>"
      data-name="Find a Teacher"
      data-description="<%= @mentor.name %>"
      data-email="<% current_user.email %>"
      data-locale="auto"
      data-zip-code="true"
      data-currency="gbp">
    </script>
  <% end %>

以下是我的事务控制器的外观:

类TransactionsController&lt; ApplicationController中

def create
    mentor =  Mentor.find_by!(slug: params[:slug])

    sale = mentor.sales.create(
        amount: (mentor.price * 100).floor,
        email_user: current_user.email,
        email_mentor: mentor.user.email,
        stripe_token: params[:stripeToken]
        )
    sale.running!

    if sale.completed?
        redirect_to pickup_url(guid: sale.guid)
    else
        redirect_to mentor_path(mentor), notice: @error
    end
end


def pickup
    @sale = Sale.find_by!(guid: params[:guid])
    @mentor = @sale.mentor
end

我不确定这两个摘录是否足以理解这个问题,我对ruby和整体编码都很陌生。如果我需要提供更多信息来解决这个问题,请告诉我。

我在下面添加了routes.rb文件:

Rails.application.routes.draw do
  devise_for :users

  resources :mentors do
    resources :reviews
  end

  root 'pages#home'
  get 'about' => 'pages#about'
  get 'bementor' => 'pages#bementor'
  get 'dashboard' => 'pages#dashboard'
  post '/call/:slug', to:'transactions#create', as: :call
  get '/pickup/:guid', to:'transactions#pickup', as: :pickup 
end

0 个答案:

没有答案