uninitialized constant Spree :: CustomModelPingsController :: CustomModelPing

0

Hi, I'm new to Rails and I'm working with the Spree Ecommerce core. Generate a new customized model (CustomModelPing) and when inserting data, I receive the following error.

        uninitialized constant 
        Spree::CustomModelPingsController::CustomModelPing
        # If the constant was actually loaded, something else went 
        wrong?
        raise if from_mod.const_defined?(const_name)
        CoreExt::ActiveSupport.without_bootsnap_cache { super }
        end

      # Signature has changed a few times over the years; easiest to 
        not

I have no problems the first time I insert data, the problem is triggered, from the second attempt onwards.

The controller is as follows:

  class Spree::CustomModelPingsController < Spree::StoreController
       before_action :set_custom_model_ping, only: [:new]
       # GET /custom_model_pings
       def index
       end

       def new
       @custom_model_ping = CustomModelPing.new
       end

       def show
       end

      def create
          @custom_model_ping 
          =CustomModelPing.new(custom_model_ping_params)
          if @custom_model_ping.save
          flash[:success] = "Buscando tu ksero mas cercano"
          #redirect_to custom_model_pings_path
          redirect_to sale_path
      else
         flash[:error] = "Formulario xxx"
         redirect_to custom_model_ping_path, danger: "Tranquilo, solo 
         necesitamos que ingreses los datos correctamente. Recuerda que 
         todos los campos son obligatorios"
         @custom_model_ping.errors
       end
     end

       def set_custom_model_ping
            @custom_model_ping = CustomModelPing.find(params[:id] 
            [:custom_model_ping])
       end
      # Only allow a trusted parameter "white list" through.
        def custom_model_ping_params
           params.require(:custom_model_ping).permit(:address, 
           :latitude, :longitude)
         end
     end

My model is:

        class Spree::CustomModelPing < Spree::Base
            geocoded_by :address
            after_validation :geocode, :if => :address_changed?
        end

The index view:

           <p id="notice"><%= notice %></p>

               <h1>Encuentra comida Casera, cerca de tu ubicación</h1>
               <%= render :partial =>'spree/custom_model_pings/form' , 
               locals: { custom_model_ping: @custom_model_ping } %>
               <br>

The partial occupied _form:

        <%= form_with(model: custom_model_ping, scope: 
            :custom_model_ping, local:true) do |form| %>

          <div class="container">
          <div class="row">
          <div class="col-lg-6">
          <div class="field">
              <%= form.text_field :address ,
              :input_html =>{:id => 'gmaps-input-address'},
              maxlength: 50, 
              placeholder: "Ingresa tu ubicación, por Ej: Presidente 
              Riesco 5536, Las Condes", 
             id: 'gmaps-input-address' , 
            class: "form-control" %>
        </div>
        </div>

       <div class="col-md-6 ">
          <i class="fa fa-money fa-2x" aria-hidden="true"></i>
          <i class="fa fa-car fa-2x" aria-hidden="true"></i>
       <div class="actions">
             <%= form.submit  class: 'btn btn-success btn-lg', value: 
             'Busca tu Ksero'%>
      </div>
      </div>
       </div>

       </div>

       </div>
      <% end %>

Please help.

    
asked by Sebastian Campos Davila 23.08.2018 в 02:35
source

0 answers