Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Feature Request: Callbacks and Filters #1293

Open
ehoch opened this Issue · 1 comment

3 participants

@ehoch

What do you guys think of "borrowing" the idea of callbacks and filters from activeadmin? You can see the comments in their code

For starters, this will definitely clean up the hack I'm using for assigning the user via a default. (It's kind of a security nightmare since I use that for my authorization and have to enable user_id in my mass assignment)

Any ideas on how we could accomplish this via rails_admin's DSL? We don't really have the concept of the "controllers" that AA has. So maybe use Proc?

So I guess my proposal would be:

config.model Post do
  before_build do
    Proc.new do
      @object.user_id = bindings[:view]._current_user.id
    end
  end
end

It's not the most graceful thing, but seems like it might be the most doable given our current DSL? Thoughts? We could easily then replicate the various active record ones...

Then a similar-ish thing for filters?

@jgaldrich jgaldrich referenced this issue in oscurrency/oscurrency
Closed

Bug: Admin adding a completed exchange #260

@ignasio

Is there any ways to get such behaviour now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.