gpt4 book ai didi

ruby-on-rails - undefined method `cookie_value' for .... Impressionist gem

转载 作者:行者123 更新时间:2023-12-02 02:31:30 27 4
gpt4 key购买 nike

我已经设置了 impressionist gem在我的电影模型中。它一直运行良好,更新了展示次数,但在尝试获取 Films#Show 页面时突然收到以下错误。

undefined method `cookie_value' for "60cb104e4befe185a8b81aac9a2c5e3c":String

好像和session_hash有关系,但是不知道怎么解决。

有没有人有什么想法?

这是我的电影模型:

    class Film < ApplicationRecord


acts_as_votable
is_impressionable

mount_uploader :cover, ImageUploader
mount_uploader :video, VideoUploader
mount_uploader :trailer, VideoUploader



def score
self.get_upvotes.size - self.get_downvotes.size
end

extend FriendlyId
friendly_id :title, use: :slugged

# one film has many reviews
has_many :reviews, dependent: :destroy

validates :title, presence: true
validates :author, presence: true
validates :cover, presence: true
validates :description, presence: true

end

电影放映页面

<%= render "shared/ticker" %>




<div class="back-to-films">
<%= link_to films_path do %>
<span><%= image_tag "BackArrow1.svg" %> </span><h3 class="back-to-gallery">Back to film gallery</h3>
<% end %>
</div>



<section class="film-show-grid">

<div class="film-show-img" onclick="toggle();">
<%= image_tag @film.cover.show.url %>
</div>

<div class="film-show-info">
<span><% if @film.is_top_pick %>
<%= image_tag "is_featured.svg", :class => "top-pick-show" %>
<% end %></span>

<span class="liking-target">
<%= link_to like_film_path(@film), class: "upvoted {liked_or_not}", method: :put, remote: :true do %>
<%= image_tag "Polygon2.svg", :class => "polygon" %>
<% end %>
<span class="like_count">
<%= @film.get_likes.size %>
</span>
</span>

<span class="views">
<%= image_tag "view.svg", :class => "eyeball" %>
<span class="impressions"><%= @film.impressionist_count(:filter=>:ip_address) %></span>
</span>




<div class="">
<h2 class="film-title"><%= @film.title %></h2>
<h6 class="film-author"><%= @film.author %></h6> <span><%= @film.description %></span>
<p class="film-description"><%= @film.description_body %></p>
</div>
<div class="play-button" onclick="toggle();">
<span> Play </span> <%= image_tag "play.svg", :class => "play-symbol" %>
</div>
<div class="preview-button" onclick="toggleTrailer();">
Trailer
</div>
<%= link_to film_reviews_path(@film) do %>
<div class="cafe-talk-button">
Café talk
</div>
<% end %>

还有我的完整堆栈跟踪

impressionist (2.0.0) app/controllers/impressionist_controller.rb:143:in `session_hash'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:60:in `associative_create_statement'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:27:in `impressionist'
app/controllers/films_controller.rb:28:in `show'
actionpack (6.0.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.2) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.2) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.3.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.2) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.2) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.2) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.2) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.3.2) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.3.2) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.0.3.2) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.0.3.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.0.3.2) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.3.2) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.2) lib/action_dispatch/routing/route_set.rb:834:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.2) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.3.2) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.2) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.4) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.4) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.4) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.4) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.2) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.3.2) lib/rails/engine.rb:527:in `call'
puma (4.3.5) lib/puma/configuration.rb:228:in `call'
puma (4.3.5) lib/puma/server.rb:713:in `handle_request'
puma (4.3.5) lib/puma/server.rb:472:in `process_client'
puma (4.3.5) lib/puma/server.rb:328:in `block in run'
puma (4.3.5) lib/puma/thread_pool.rb:134:in `block in spawn_thread'

最佳答案

我将使用 impression gem 的遗留 Rails 应用程序更新到版本 6 并遇到了相同的异常。我通过在 Gemfile 中为 impression gem 指定一个特定的提交来解决它:

gem 'impressionist',
git: 'git@github.com:charlotte-ruby/impressionist.git',
ref: '46a582ff8cd3496da64f174b30b91f9d97e86643'

原因是 fix因为异常不在他们的最新版本 (2.0.0) 中,而是在其 master 分支中。

关于ruby-on-rails - undefined method `cookie_value' for .... Impressionist gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64969386/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com