Prezados,
Ao clicar em destroy o alert para clicar em ok não está sendo exibido, ele está redirecionando para uma pagina onde permite Edit e Back, não consigo excluir o item. Tentei em navegadores diferentes e o problema é o mesmo.
O que pode ser?
Prezados,
Ao clicar em destroy o alert para clicar em ok não está sendo exibido, ele está redirecionando para uma pagina onde permite Edit e Back, não consigo excluir o item. Tentei em navegadores diferentes e o problema é o mesmo.
O que pode ser?
Por favor, você pode postar o código para olharmos?
Segue log servidor, parece que ao clicar no destroy está redirecionando para pagina errada.
C:\used_cars>rails server
DL is deprecated, please use Fiddle
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run rails server -h
for more startup options
=> Ctrl-C to shutdown server
[2015-01-29 23:41:40] INFO WEBrick 1.3.1
[2015-01-29 23:41:40] INFO ruby 2.1.5 (2014-11-13) [x64-mingw32]
[2015-01-29 23:41:40] INFO WEBrick::HTTPServer#start: pid=7264 port=3000
Started GET "/cars" for ::1 at 2015-01-29 23:41:47 -0200 ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations". FROM "schema_migrations" Processing by CarsController#index as HTML Car Load (0.0ms) SELECT "cars". FROM "cars" Rendered cars/index.html.erb (32.0ms) Completed 200 OK in 201ms (Views: 143.1ms | ActiveRecord: 1.0ms)
Started GET "/cars/1" for ::1 at 2015-01-29 23:42:01 -0200 Processing by CarsController#show as HTML Parameters: {"id"=>"1"} Car Load (1.0ms) SELECT "cars".* FROM "cars" WHERE "cars"."id" = ? LIMIT 1 [["id", 1]] Rendered cars/show.html.erb (4.0ms) Completed 200 OK in 121ms (Views: 51.0ms | ActiveRecord: 1.0ms)
Controlador
class CarsController < ApplicationController before_action :set_car, only: [:show, :edit, :update, :destroy] --# GET /cars --# GET /cars.json def index @cars = Car.all end
--# GET /cars/1 --# GET /cars/1.json def show end -- # GET /cars/new def new @car = Car.new end
-- # GET /cars/1/edit def edit end
--# POST /cars -- # POST /cars.json def create @car = Car.new(car_params)
respond_to do |format| if @car.save format.html { redirect_to @car, notice: 'Car was successfully created.' } format.json { render :show, status: :created, location: @car } else format.html { render :new } format.json { render json: @car.errors, status: :unprocessable_entity } end end end
--# PATCH/PUT /cars/1 --# PATCH/PUT /cars/1.json def update respond_to do |format| if @car.update(car_params) format.html { redirect_to @car, notice: 'Car was successfully updated.' } format.json { render :show, status: :ok, location: @car } else format.html { render :edit } format.json { render json: @car.errors, status: :unprocessable_entity } end end end
--# DELETE /cars/1 --# DELETE /cars/1.json def destroy @car.destroy respond_to do |format| format.html { redirect_to cars_url, notice: 'Car was successfully destroyed.' } format.json { head :no_content } end end
private -- # Use callbacks to share common setup or constraints between actions. def set_car @car = Car.find(params[:id]) end
-- # Never trust parameters from the scary internet, only allow the white list through. def car_params params.require(:car).permit(:brand, :model, :year) end end
Consegui resolver reinstalando o rails. Obrigado!