Routing Error undefined method `hide_action' for ApplicationController:Class

119 views
Skip to first unread message

Emanuel Coen

unread,
Aug 2, 2018, 8:44:09 AM8/2/18
to Public Activity

Hi I am following this tutorial but the hide_action trick does not work as the method is deprecated in Rails 5.


Does anyone know how I can circumvent the problem?






Piotrek Okoński

unread,
Aug 2, 2018, 8:47:46 AM8/2/18
to Emanuel Coen, Public Activity
Hey, Emanuel!

You don't need `hide_action` anymore. Simply define the `current_user` method in your ApplicationController without hiding it. There are no routes to it, so it won't be treated as an action :)

Cheers

--
You received this message because you are subscribed to the Google Groups "Public Activity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to public-activity+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Emanuel Coen

unread,
Aug 2, 2018, 9:02:59 AM8/2/18
to Public Activity
Hi Piotr, 

Thanks a lot for your fast answer! I tried to do that but the problem when I do that is that it screws up my entire app. I think it's because I use current_user in a lot of other parts in the app.

For example my navbar should normally display the user's avatar etc. instead of sign up button but now that logic doesnt work anymore. Also I get current_user is nil errors in a lot of parts of the app. I attached two screenshots to make it more clear.




Am Donnerstag, 2. August 2018 14:47:46 UTC+2 schrieb Piotrek Okoński:
Hey, Emanuel!

You don't need `hide_action` anymore. Simply define the `current_user` method in your ApplicationController without hiding it. There are no routes to it, so it won't be treated as an action :)

Cheers
On 2 August 2018 at 14:44, Emanuel Coen <emanu...@gmail.com> wrote:

Hi I am following this tutorial but the hide_action trick does not work as the method is deprecated in Rails 5.


Does anyone know how I can circumvent the problem?






--
You received this message because you are subscribed to the Google Groups "Public Activity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to public-activi...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Piotrek Okoński

unread,
Aug 2, 2018, 9:03:49 AM8/2/18
to Emanuel Coen, Public Activity
What authentication solution do you use? Is it devise?

To unsubscribe from this group and stop receiving emails from it, send an email to public-activity+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Emanuel Coen

unread,
Aug 2, 2018, 9:10:11 AM8/2/18
to Public Activity
Correct!

Piotrek Okoński

unread,
Aug 2, 2018, 9:10:36 AM8/2/18
to Emanuel Coen, Public Activity
Then you can completely skip defining your own `current_user` method, it's already there and ready to use :)

To unsubscribe from this group and stop receiving emails from it, send an email to public-activity+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Emanuel Coen

unread,
Aug 2, 2018, 9:13:09 AM8/2/18
to Public Activity
Haha that is the punishment for blindly following tutorials without properly understanding. 

Thanks so much you made my day !! :)

Piotrek Okoński

unread,
Aug 2, 2018, 9:13:41 AM8/2/18
to Emanuel Coen, Public Activity
No worries, happens to everyone :D Glad you got it working 👌

To unsubscribe from this group and stop receiving emails from it, send an email to public-activity+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Emanuel Coen

unread,
Aug 2, 2018, 9:30:24 AM8/2/18
to Public Activity
Another question :D Do you know why this doesn't work? (Sorry learning rails for three weeks now)

Piotrek Okoński

unread,
Aug 2, 2018, 9:32:40 AM8/2/18
to Emanuel Coen, Public Activity
You are trying to execute controller methods (`list` and `show`) on a Model instance. This won't work. Get rid of `.list.` and `.show` from that line. 



To unsubscribe from this group and stop receiving emails from it, send an email to public-activity+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Emanuel Coen

unread,
Aug 2, 2018, 10:05:58 AM8/2/18
to Public Activity
Excellent it works!! One very last question. 

I have implemented a follow logic with the "acts_as_follower" gem. That works perfectly now! Do you know how I can twitch the public activity so that it just shows activites of users that I follow?

Emanuel Coen

unread,
Aug 2, 2018, 10:43:26 AM8/2/18
to Public Activity
I am almost there with : 

@activities = ::PublicActivity::Activity.order("created_at desc").where(owner_id: current_user.all_following, owner_type: "User")

but the problem is that the all_following method returns an array whereas I need just the user_id's within that array

Emanuel Coen

unread,
Aug 2, 2018, 12:39:40 PM8/2/18
to Public Activity
I have everything working now! Forget my other questions. Have a good day :)


Am Donnerstag, 2. August 2018 15:32:40 UTC+2 schrieb Piotrek Okoński:
Reply all
Reply to author
Forward
0 new messages