RubyFlow The Ruby and Rails community linklog

Fetch current user in models

I wrote an article Fetch current user in models, you may know it, but this technique is useful for new comer.

Comments

This is one of those things that seems like a helpful idea & then you end up in situations where you start to remember why we all turned our back on interwoven request-centric code at every level of the app.

This is realy bad idea! Dont!

This is a very bad practice, sorry.

All he’s doing is allowing the Observer to access the current user to track who is modifying the model. How else are you going to do this? Duplicate all that code across controllers? No, that’s what Observers are for.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in