Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `service_path' when adding best_in_place #614

Open
felixpro opened this issue May 20, 2019 · 0 comments
Open

undefined method `service_path' when adding best_in_place #614

felixpro opened this issue May 20, 2019 · 0 comments

Comments

@felixpro
Copy link

I have an application that has customers and services. Customers has_many services and service belongs_to customer. In the customer show page, I can add or delete services. But I can not edit services, so I'm using best_in_place to do that. but is not working. It returns undefined method `service_path'. I will appreciate any help, I'm new in software.

here is the repository link if you want to check the whole app.

https://github.com/felixpro/ars-reclama/commits/master

I restarted the server, but it keeps returning the same error.

customer/show.html.erb


   <% @customer.service.each do |service| %>
      <%= best_in_place service, :process  %>
   <% end %>
customer_controller.rb

def show
    @customer = Customer.find params[:id]
    @service = @customer.service.order('created_at DESC').limit(4)
  end


  def edit
    @customer = Customer.find params[:id]
  end

service_controller.rb

  def edit
    @customer = Customer.find params[:id]

    @service = @customer.services.find(params[:id])
  end


  def update
    @service = Service.find(params[:id])

    respond_to do |format|
      if @service.update(service_params)
        format.html { redirect_to @service, notice: 'Service was successfully updated.' }
        format.json { render :show, status: :ok, location: @service }
      else
        format.html { render :edit }
        format.json { render json: @service.errors, status: :unprocessable_entity }
      end
    end
  end

routes.rb

resources :customers do
    resources :services

  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant