-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to specify primary key #35
Comments
You should be able to implement this using the to_param and using a before filter in the resource. I haven't actually tested this, so let me know if this works... But it should look something like this. class Post < ActiveRecord::Base
def to_param
uuid
end
end
ActiveAdmin.register Post do
before_filter :only => [:show, :edit, :update] do
@post = Post.find_by_uuid(@post)
end
end Active Admin should use the @post variable instead of looking it up if you have already defined it. Again, I haven't had a chance to test this out, but we use this method for show screens in our app. I'm assuming it will work for the edit and update. Let me know how it goes. |
Actually this should read:
Adding the ! gives you the nice 404 behavior, and @post is not defined at this point, params[:id] is. |
@malyk did this work for you? |
Greg I actually never tried it. Got caught up on other things. If I do give it another go (which I do want to do when time permits) I'll let you know. Thanks for looking into it. |
Cool. Thanks @malyk |
I found a way to do this that leverages i_r's
|
thanks @sbeam, worked like a charm |
Thanks @sbeam. Was looking for a while! |
Don't see how to set the primary key column. I have UUID as the primary key of a few tables.
The text was updated successfully, but these errors were encountered: