Created
April 2, 2019 16:48
-
-
Save localhostdotdev/8e4fd32328ea98629137e922da380b95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hey guys I got a problem with my reviews controller when it comes to post a review, I'm using devise , is a online shop, and To post a review Im using AJAX, but the AJAX does not work | |
# this is my ReviewsController: | |
class ReviewsController < ApplicationController | |
#before_action :set_shirt, only: [:show] | |
def create | |
@shirt = shirt_url.find(params[:shirt_id]) | |
@review = Review.new(review_params) | |
@review.shirt = @shirt | |
if @review.save! | |
respond_to do |format| | |
format.html { redirect_to shirt_path(@shirt) } | |
format.js # will render 'app/views/reviews/create.js.erb' | |
end | |
else | |
respond_to do |format| | |
format.html { render 'shirts/show' } | |
format.js # idem | |
end | |
end | |
end | |
private | |
def review_params | |
params.require(:review).permit(:content) | |
end | |
end | |
# and this ones my routes: | |
=begin | |
root GET / pages#home | |
shirt_reviews POST /shirts/:shirt_id/reviews(.:format) reviews#create | |
shirts GET /shirts(.:format) shirts#index | |
shirt GET /shirts/:id(.:format) shirts#show | |
order_payments POST /orders/:order_id/payments(.:format) payments#create | |
new_order_payment GET /orders/:order_id/payments/new(.:format) payments#new | |
orders POST /orders(.:format) orders#create | |
order GET /orders/:id(.:format) | |
=end | |
# if You need something more just let me know thanks in advance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.reddit.com/r/rails/comments/b8limc/actioncontrollerurlgenerationerror/