Я попытался изменить существующий проект с базы sqlite3 на базу postgresql, и я получил эту последнюю ошибку, которую не знаю, как ее решить.
blog_path в следующем html-файле запускает неопределенный методОшибка 'blog_path'
<!DOCTYPE html>
<html>
<head>
<title>My Blog</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
</head>
<body>
<h1>My Blogs</h1>
<div class="main">
<div class="left-block">
</div>
<div class="blog-container">
<% @blogs = @blogs.reverse %>
<% @blogs.each do |blog| %>
<div class="blog">
<p class="title"><%= blog.title %></p>
<p class="time"><%= blog.created_at %></p>
<%= link_to 'Learn More', blog_path(blog), class: "btn btn-info" %>
</div>
<% end %>
</div>
<div class="right-block">
</div>
</div>
<footer>
<%= link_to 'New Blog', '/blogs/new', class: "btn btn-primary" %>
</footer>
</body>
</html>
Это класс блога
class Blog < ApplicationRecord
end
Это route.rb в папке конфигурации
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get '/blogs' => 'blogs#index'
get '/blogs/new' => 'blogs#new'
post '/blogs' => 'blogs#create'
get '/blogs/:id' => 'blogs#show'
get '/blogs/:id/edit' => 'blogs#edit'
patch '/blogs/:id' => 'blogs#update'
delete '/blogs/:id' => 'blogs#destroy'
end
Это blogs_controller.rb
class BlogsController < ApplicationController
def index
@blogs = Blog.all
end
def new
@blog = Blog.new
end
def create
@blog = Blog.new(blog_params)
if @blog.save
redirect_to blogs_url
else
render 'new'
end
end
def show
@blog = Blog.find(params[:id])
end
def edit
@blog = Blog.find(params[:id])
end
def update
@blog = Blog.find(params[:id])
@blog.update_attributes(blog_params)
redirect_to blogs_url
end
def destroy
@blog = Blog.find(params[:id])
@blog.destroy
redirect_to blogs_url
end
private
def blog_params
params.require(:blog).permit(:title, :content)
end
end
** Пожалуйста, дайте мне знать, нужны ли какие-либо другие ресурсы для решения этой проблемы.