使用提交表单Shopify App Proxy将无法正确提交

时间:2014-01-22 01:55:17

标签: ruby-on-rails ajax forms shopify

我尝试添加多个应用代理位置,但尽管看起来像它允许你,多个链接没有保存到我的应用程序。我目前有一个表格很好,但提交后我不确定如何处理它?使用Ajax提交并呈现消息?这是我现在的控制器,但在提交时根本没有达到创建操作。

class ProductsController < ApplicationController
    before_filter :customer_authenticate

    def create
        product = Product.create(params[:product])
        if product.update_attribute(:shopify_id, product.set_up_product)
            flash[:notice] = 'Product was successfully submitted'
            redirect_to new_products_url
        else
            flash[:notice]= product.errors.full_messages
            redirect_to :back
        end
    end

    def new
      if params[:shop].present? && @store = Store.find_by_shopify_url(params['shop']) 
        render layout: false, content_type: 'application/liquid'
      else
        flash[:notice] = 'Application is not setup with store, please try again'
        redirect_to welcome_url
      end
  end

  private

  def customer_authenticate
    if params['shop']
        store = Store.find_by_shopify_url(params['shop']) 
    else
        store = Store.find(params[:store_id])
    end
    sess = ShopifyAPI::Session.new(store.shopify_url, store.access_token)
    ShopifyAPI::Base.activate_session(sess)
    session[:shopify] = sess
  end
end

1 个答案:

答案 0 :(得分:0)

由于网站是通过代理访问的,因此URL帮助程序不起作用,所以我必须在表单中指定如下所示的位置,现在效果很好。

<%= form_for(@product, url: ENV['HOME_URL'] + "/products", method: :post, html: {multipart: true}) do |f| %>