-
-
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
Rails 4 #2326
Rails 4 #2326
Conversation
Hey guys,
|
That's because you need to define the attributes that are accessible: ActiveAdmin.register AdminUser do
controller do
def permitted_params
params.permit user: [:first_name, :last_name, :username, :age]
end
end
end I'll add a commit that updates the app generator to auto-add this to the AdminUser file. |
Bizarre: When I do that, I get "can't be blank" validation errors for the email and password fields. |
How is that bizarre? IIRC, those are validations that Devise adds in. |
The bizarre bit is that I'm inputting values and getting the validation errors. |
Ah... The code I listed was wrong. It should be this: params.permit admin_user: [:email, :password, :password_confirmation] |
That fixed it. Thanks @daxter. Much appreciated. So I guess the it's: params.permit snake_cased_resource_name: [:array, :of, :symbols, :corresponding, :to, :input, :names] to white-list params. |
Yep. More info can be found here. But basically this whitelists certain param keys to be used in mass assignment.
You have to whitelist that param like so: params.permit admin_user: [:email] |
Perfect, thanks again. |
FYI I just noticed that for a relationship, you have to use the db field name e.g. if you have a Post resource that's modeled: class Post < ActiveRecord::Base
# includes id, title, slug, blurb, content, category_id db fields
belongs_to :category
end Then the app/admin/posts.rb resource file would be: ActiveAdmin.register Post do
# ...
controller do
def permitted_params
params.permit post: [:title, :slug, :blurb, :content, :category_id]
end
end
end Note category_id, not category. Now does this mean that the parameter array in the |
You should look at the HTML of the form. It most likely uses |
Yes, yes it does. Thank you for your patient clarification. |
I did everything you said above. And I have an issue with inheritance classes: Issue #2366 |
I had the same question. Thanks a lot! |
@daxter It might be a good idea to add a section to the README which includes the Rails 4 specific setup. |
For some reason, Formtastic checks if a constant is defined first, which doesn't play nicely with autoloading of custom inputs. This brings Formtastic's implementation back to pre formtastic/formtastic#783
Since our major dependencies now have official rubygems releases that support both Rails 3.2 and 4.0, I'm making those new versions a requirement in the gemspec.
@gregbell I'm working on merging this into master. The only real difficulty is gem version requirements. Looking it over, I'm tempted to remove version requirements for asset gems: s.add_dependency "arbre", "~> 1.0"
s.add_dependency "bourbon"
s.add_dependency "coffee-rails"
s.add_dependency "devise", "~> 3.0"
s.add_dependency "formtastic", "~> 2.3"
s.add_dependency "inherited_resources", "~> 1.3"
s.add_dependency "jquery-rails"
s.add_dependency "jquery-ui-rails"
s.add_dependency "kaminari", "~> 0.13"
s.add_dependency "rails", ">= 3.2", "< 4.1"
s.add_dependency "ransack", "~> 1.0"
s.add_dependency "sass-rails" Especially since these gems have their own version requirements for Rails, it should work out fine. |
Off topic: You can simplify the Rails version to "~> 4.0.0" |
No, |
👍 |
Meh, for now I'm going to go with that versioning scheme. It can always be changed later. |
Conflicts: activeadmin.gemspec lib/active_admin/base_controller/authorization.rb lib/active_admin/dependency_checker.rb
Congrats everyone, 0.6.1 has been released so this branch has been merged into master! 💃 Note that while doing so I ran into a new bug: #2497 |
Awesome. Thanks everyone who was involved in this. |
@daxter, you are my hero! 😻 |
Hooray! Can't wait to see this cut into a new proper release. 🚢 👍 |
👍 |
👍 Cant wait !! |
When I done it as the instruction says, I got an error on bundle step: fatal: ambiguous argument 'rails4': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' ... |
There is no longer a gem 'activeadmin', github: 'gregbell/active_admin' |
@shekibobo |
Hey everyone! Active Admin should now be ready for use with Rails 4. Previously you had to specify multiple gems to use the latest code on their repo, but now Active Admin is the only one that doesn't have an official release. For now, this is all you need to specify:
Note that Rails 4 introduces a new API for mass-assignment protection. You should use this pattern for every model:
If you have any troubles, please post here if it's something small, or otherwise open a new Issue.
Thanks to everyone who helped identify issues in #1963, and especially thank you to everyone who submitted code ❤️