Vincent Robert

Joined

260 Experience
2 Lessons Completed
0 Questions Solved

Activity

Posted in How to use Devise with Hotwire & Turbo.js Discussion

Hello.
Has anyone managed to use the "current_user" method from Devise in broadcasted partial views?

I have merged the 2 applications "hotwire-devise" & "hotwire-twitter-clone",
and when I add a call to current_user
(like for instance <%= link_to "Edit", edit_tweet_path(tweet) if current_user.present? %> in the _tweet.html.erb file),
I get an error because the method is not available in this context:

Started POST "/tweets" for 127.0.0.1 at 2021-01-29 14:45:53 +0100
Processing by TweetsController#create as TURBO_STREAM
Parameters: {"authenticity_token"=>"[FILTERED]", "tweet"=>{"body"=>"TEST"}, "commit"=>"Create Tweet"}
Tweet Create (0.8ms)  INSERT INTO "tweets" ("body", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"  [["body", "TEST 003"], ["created_at", "2021-01-29 13:45:53.776383"], ["updated_at", "2021-01-29 13:45:53.776383"]]
Rendered tweets/_tweet.html.erb (Duration: 4.3ms | Allocations: 2000)
Completed 500 Internal Server Error in 30ms (ActiveRecord: 19.6ms | Allocations: 5713)

ActionView::Template::Error (Devise could not find the `Warden::Proxy` instance on your request environment.
Make sure that your application is loading Devise and Warden as expected and that the `Warden::Manager` middleware is present in your middleware stack.
If you are seeing this on one of your tests, ensure that your tests are either executing the Rails middleware stack or that your tests are using the `Devise::Test::ControllerHelpers` module to inject the `request.env['warden']` object for you.):
 6:       <%= button_to "Likes (#{tweet.likes_count})", tweet_like_path(tweet), method: :post %>
 7:       <%= button_to "Retweets (#{tweet.retweets_count})", tweet_retweet_path(tweet), method: :post %>
 8: 
 9:       <%= link_to "Edit", edit_tweet_path(tweet) if current_user.present? %>
10:     </div>
11:   </div>
12: <% end %>

Hi Chris.
Would it be possible to add a feature on GoRails in order to manually "mark as watched" an episode?
When I randomly select an episode to watch, I would like to list only those that I have not watched yet.
Thank you for your work.
Vincent

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.