Я получаю это сообщение об ошибке (Не удается найти портфолио с идентификатором '= редактировать), когда я пытаюсь изменить свою страницу показа.
def set_portfolio_item
@portfolio_item = Portfolio.find(params[:id])
end
Я попытался изменить идентификатор, поставивредактировать там, но все равно не работает
class PortfoliosController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :set_portfolio_item, only: [:edit, :show, :update, :destroy]
layout 'portfolios'
access all: [:show, :index, :angular], user: {except: [:destroy, :new, :create, :update, :edit, :sort]},site_admin: :all
def index
@portfolio_items = Portfolio.by_position
@page_title = "Portfolios"
end
def sort
params[:order].each do |key, value|
Portfolio.find(value[:id]).update(position: value[:position])
end
render json: { status: "updated" }
end
def new
@portfolio_item = Portfolio.new
3.times { @portfolio_item.technologies.build }
end
def create
@portfolio_item = Portfolio.new(portfolio_params)
respond_to do |format|
if @portfolio_item.save
format.html { redirect_to portfolios_path, notice: 'Your portfolio item is now live.'}
else
format.html { render :new }
end
end
end
def edit
end
def update
respond_to do |format|
if @portfolio_item.update(portfolio_params)
format.html { redirect_to portfolios_path, notice: 'The record successfully updated.' }
else
format.html { render :edit }
end
end
end
def show
end
def destroy
#this going to perform the look up
# Destroy/delete the record
@portfolio_item.destroy
# Redirect
respond_to do |format|
format.html { redirect_to portfolios_url, notice: 'Post was removed.' }
end
end
private
def portfolio_params
params.require(:portfolio).permit(
:title,
:subtitle,
:body,
:main_image,
:thumb_image,
technologies_attributes: [:name]
)
end
def set_portfolio_item
@portfolio_item = Portfolio.find(params[:id])
end
end
при нажатии на http://localhost:3000/portfolios/edit
, я ожидал перейти на страницу редактирования шоу, но получаю
ActiveRecord :: RecordNotFoundв PortfoliosController # show Не удалось найти портфолио с 'id' = edit
это мои маршруты для шоу
portfolios_show GET /portfolios/:id(.:format) portfolios#show
blog GET /blogs/:id(.:format) blogs#show
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format)
active_storage/disk#show
это мой маршрут для редактирования
edit_user_password GET /password/edit(.:format) devise/passwords#edit
edit_user_registration GET /edit(.:format) devise/registrations#edit
edit_portfolio GET /portfolios/:id/edit(.:format) portfolios#edit
edit_blog GET /blogs/:id/edit(.:format) blogs#edit