如何解决如何使用印象派 gem rails 修复此错误
嗨,我对印象派宝石有误。我使用 Rails 5.2.4.4
我做了这些步骤:
宝石“印象派”
然后捆绑安装
然后 Rails g 印象派和捆绑安装
然后下一步:
in my blogs_controllers
class BlogsController < ApplicationController
before_action :authorize_admin,only: [:new,:edit,:create,:update]
before_action :set_blog,only: [:show,:update,:destroy]
impressionist :actions => [:show,:index]
def index
@categories = Category.all
cate = params[:cate]
if !cate.nil?
@blogs = Blog.where(:category_id => cate)
else
@blogs = Blog.all
end
end
def show
impressionist(@blog)
end
def new
@blog = Blog.new
end
def create
@blog = Blog.new(blog_params)
if @blog.save
redirect_to blog_path(@blog),notice: "Successfully Created"
else
render :new
end
end
def edit
end
def update
@blog.slug = nil
if @blog.update(blog_params)
redirect_to blog_path(@blog),notice: "Successfully Update"
else
render 'edit'
end
end
def destroy
@blog.destroy
redirect_to blogs_path
end
private
def set_blog
@blog = Blog.find(params[:id])
end
def blog_params
params.require(:blog).permit(:title,:body,:image,:category_id)
end
def authorize_admin
return unless !current_user.admin?
redirect_to root_path
end
end
在博客模型中
is_impressionable
在博客展示
<%= @blog.impressionist_count(:filter=>:ip_address) %>
我得到了这个错误:
BlogsController#show 中的名称错误
未初始化的常量 ActiveSupport::ParameterFilter 提取的源代码(围绕第 80 行):
# If the constant was actually loaded,something else went wrong?
raise(e) if from_mod.const_defined?(const_name)
CoreExt::ActiveSupport.without_bootsnap_cache { super }
end
# Signature has changed a few times over the years; easiest to not
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。