RailsCasts Pro episodes are now free!
Learn more or hide this
Can I integrate with anything other than devise?
Does it works with other ORMs? (didn't have the time to test it yet)
You can change the current_user_method in the config/initializers/active_admin.rb file to use something else. I'm not sure what other dependencies Active Admin has on Devise though.
any thoughts on choosing between activeadmin and railsadmin?
Rails Admin looks great as well, but I didn't feel it was ready to be covered. A gem hasn't been recently released. I will probably cover it in a future episode after it reaches a stable point.
What your opinion about active scaffold? How good is it compared to activeadmin?
I used ActiveScaffold on a large project in Rails 2.3. I was able to customize everything I needed but it wasn't easy for complex cases. I believe the main fork is not being upgraded to Rails 3.
I've been using ActiveAdmin and agree that it's beautiful and initially feels like a great choice to get started. However, I found myself spending a lot of time fighting the gem to build an app around it. I think it's best suited to use as a customizable scaffold system and that's it. One problem I had was that it uses a DSL-generated layout, so you can't integrate it easily into an existing app. It's really designed around management of resources, not as a general-purpose application framework. All in all, very powerful but it makes things that are easy in Rails a bit harder sometimes.
I'm investigating a switch to Rails Admin myself. It seems to be a bit less automatic and more the "Rails Way", but it may be too early to say.
I agree with Doug Puchalski, I've been using Active Admin for some time now, and also found myself fighting with it constantly to get it to do things I wanted. I have several blog posts dedicated to some workarounds I found.
Active Admin looks beautiful and works great if you don't want to push it too far. I recently dropped Active Admin in favor of a manual hand-coded version for several reasons. I found the release cycle very slow. I also didn't like the dependence on Formtastic and Devise.
Kudos to the guys who put it together though, it really is a nice gem. It just doesn't fit a project that needs a lot of customizing.
How does activeadmin handle many-to-many relationships?
Did you ever get anywhere with this question? I'm struggling with the same thing.
Struggling too. Did you get anywhere sofar?
ActiveAdmin is absolutely amazing! Thank you for doing a screencast on this.
On a side note, are you aware of the issues that ActiveAdmin has with Rails 3.1 on Heroku? I've been playing around with it for some time and haven't found a reasonable answer.
I second this! I've spent hours trying to get it to deploy but keep generating errors! Something to do with SASS i think.
Did you come up with a solution?
Works for me on heroku, application.rb
I am running into the error discussed in this area of the devcenter.
I am not sure exactly how to resolve or debug at this time, but I will report back if I find anything.
ActiveAdmin does work with this command, just not the rake assets:precompile. Just make sure you migrate Heroku's database, too.
Moving the sass-rails gem out of the :assets group as @autodidakto says below lets me run the db migrations, but I'm still having the rake assets:precompile issues on heroku cedar.
There is an open issue for that
Not yet, but I will be trying @bnerd's solution first.
gem 'sass-rails', " ~> 3.1.0"
out of the :assets group.
assets load last, active admin needs sass to load sooner.
instead of moving sass-rails outside the :assets group, we just need to put 'activeadmin' after that group, does it work?
There's quite a bit of discussion of sass in the GitHub issues.
I'm not yet running 3.1, but I got around a similar sass problem in 3.0 by generating the assets locally, then putting this in an initializer:
Sass::Plugin.options[:never_update] = true
Sass::Plugin.options[:never_update] = true
For running active_admin on Heroku add that line to your config/environments/production.rb.
config.assets.precompile += ['active_admin.js', 'active_admin.css']
And after that run rake assets:precompile, add public/assets to git, push to heroku and enjoy.
Also check that option in production.rb (should be false for heroku).
config.assets.compile = false
Thanks for another great video!
I have an issue though: I have a country which has_many regions. The region table in active admin shows the listbox with countries nicely, but it shows hash values like "Country:00x000345" instead of the actual countries. What am I doing wrong here? Thanks!
You might wanna check the documentation for this but in general you need to implement one of the following methods to_s, name, label, to_label to your model. ActiveAdmin will go through these to find a suitable text label for your model
to_s, name, label, to_label
Didn't ask it myself, but helped me. thanks!
I they no way to customize the fields in the creation of products page(new page)
Nice. Thank you. I'm just wondering how to use active admin with MongoID?
Thank you very much for this cast, Ryan!
I am using rails 3.0.10.
It seems, ActiveAdmin overwrites my active-admin.css file every time I reload a page.
I am trying to organize the section panel on the dasboard beneath each other. Therefore I tried to wrap them into custom divs.
Is there a better way to achieve this?
Put your custom css in a separate file and tell ActiveAdmin to load it: https://github.com/gregbell/active_admin/issues/261
I'm so confused now! I'm starting a new project at the moment and I want to use Sorcery from the last video and Active Admin from this one but Active Admin depends on Devise! Booo!
What to do.....
I did exactly this. My public user models are made with sorcery. I then used activeadmin and devise to build the back office for me to use.
If you are ok with separate user and admin_user models this isn't a problem.
Did you have any issues with the two gems conflicting or was it pretty straight forward?
Input for datetime is blank, is it possible to show current datetime onload?
As usually your screencast are great learning tools, the rails community is so generous with their time and expertise.
I have been playing around with active_admin and really like it.... Kudos to GregBell!!
On the gotcha with stylesheet issue, I found that moving the active_admin.css.scss to the /vendor/assets/stylesheet also solved AA overriding my css.
Thanks again for all you do!
I want to rename the resources by use i18n. How should i do?
Translations for Active Record Models
This method will help you, if i understood you correctly.
Another really great screencast, thanks!
I would LOVE to see Mongoid support. We're using mongoid in a few companies I work for and active admin would be a great addition. I see there was talk in github issues of including additional ORM support back in June - I wonder what's happened with that?
Hi, there! Excellent Railscasts as always!
I've been considering some ORMs for Rails during long time (experimented with Hobo, ActiveScaffold, even switched to Python to give it a try with Django). ActiveAdmin's backend looks nice, but must recognise I'm currently using Typus (https://github.com/typus/typus) and I can say it's fully customizable (ready to use for most of cases). It really deserves to have a deep look.
Thanks and congrats for these awesome lessons (following every week!)!!
Bare bones Devise vis a vis Sorcery:
Bare Bones Devise
I really like the gem but it is extremely slow for me. Is anyone else experiencing this?
yeah having issues with this too. i've been trying rails_admin its pretty nice too.
i think both of them are very early/unstable. but feel that rails_admin is abit more solid.
Nice screencast as always! I've been using ActiveAdmin for a while and it's a great admin interface. The only downside is that it doesn't get along to well with CanCan, it would be great to have different roles that can access the admin interface of an app and limit their actions with CanCan.
ActiveAdmin is great when you need a set of screens to let you manage your data directly. It saves having to build and test extra screens that you never plan to roll out to general users. If you spend too much time customising ActiveAdmin then perhaps you should be building a custom screen for that function.
Hi Ryan, Thanks so much for another great screencast. I totally learnt Rails following your screencasts. I noticed that ActiveAdmin using devise, what's the best way to authorize admin panel to the users who have roles of Administrator. I was using CanCan. Do active admin have anything for Authorization or do we have to integrate it through CanCan?
Does anyone have some guidance as to how to integrate Active Admin with Sunspot? I think it would be great if the filters on the right hand side of each index would search Solr rather than the underlying SQL.
Is it possible to do nested resources with activeadmin?
on level nested only...
I have lambda scope in myModel. How can I add lambda param to scope section in ActiveAdmin.register myModel?
I wish someone had an answer for this
Not well documented at all, but I found an answer so I'll answer here because Google brought me here:
ActiveAdmin.register Post do
scope :posted_by_tom_cruise do
I get an error when I try view the admin page for my model. Any idea what could cause this?
undefined method `generate_association_input_name' for #ActiveAdmin::FilterFormBuilder:0x0000010411a440
Use formtastic 1.2.x - https://github.com/gregbell/active_admin/issues/499
When I follow create or edit link I get the following error: "undefined method `_input' for #ActiveAdmin::FormBuilder:0x105b9a040" in gems/activeadmin-0.3.2/app/views/active_admin/resource/edit.html.arb
Using formtastic 1.2.4 seems to make no affect -- the error still occurs
It seems that the error occurs while rendering input for field with custom pgsql type (something like CREATE TYPE foo_type AS ENUM ... )
Yes, adding f.input :foo, :as => :string to form for such a field resolved the issue
Two questions: 1) how to display debug current_user. I went inside the gem and tried to insert it on the views but it doesn't display anything. 2) how to preset a value in the controller. I already tried in the regular controller and in the active admin controller override and it doesn't work: something like @website.user_id = current_user.id
I'd like to issue a warning:
This is nice for a very simple CRUD admin. Once you get to customizing it to fit your admin, it gets fairly involved fast.
The documentation comes up short, which shows in the amount of issues raised on github.
Ask yourself if you'd rather spend the time designing your own GUI rather than fussing with Activeadmin.
Ryan, your gotcha applies to the application.js manifest as well
And another gotcha: if you have 'will_paginate' in your Gemfile, it must be set to '3.0.pre2'
Thanks for another informative 'cast!
Hey guys - anyone else try to get it to admin your User or AdminUser models?
It seems to just edit the fields directly, and shows the encrypted password - where RailsAdmin would understand Devise and give you a regular password field that would work for password changes.
I want to use this to admin Users too :)
Did you find a solution Troy?
I like Active Admin a lot so far but haven't been able to find any info on editing passwords.
ActiveAdmin.register User do
form do |f|
f.inputs :email, :password, :password_confirmation
It worked after I added this in the active admin's resource file -
What's the best way to handle ActiveAdmin's resources in Rails 3.0.5 under a scope?
I got the routes for the pages themselves, but Images and CSS don't come through. Suggestions?
A nice enhancement in version 0.3.2, you can turn your site title into a link. For instance to get out of admin mode and back to your regular site:
config.site_title_link = :root
I've been trying to add ckeditor to the form. I have tried using the formtastic dsl but the toolbar dosen't appear.I am using rails3-ckeditor.
Thanks Ryan for this. I had tried the gem before you release this tut and i love it straight off. I have a little problem, maybe you have the answer. How do i add a different role? like user. I have tried following the device way. rails generate devise:views users but it doesn't seem to work. Any ideas?
rails generate devise:views users
Works great. One thing I had to do in order for "Sign Out" to work properly with Devise was to make the following change in initializers/active_admin.rb:
config.logout_link_method = :delete
when i sign in admin panel i get this error.I don't know why?
ArgumentError in Admin::DashboardController#index
wrong number of arguments (2 for 1)
activeadmin (0.3.2) lib/active_admin/arbre/context.rb:15:in respond_to?'
rack (1.3.4) lib/rack/etag.rb:56:injoin'
rack (1.3.4) lib/rack/etag.rb:56:in digest_body'
rack (1.3.4) lib/rack/etag.rb:26:incall'
rack (1.3.4) lib/rack/conditionalget.rb:25:in call'
actionpack (3.1.1) lib/action_dispatch/middleware/head.rb:14:incall'
rack (1.3.4) lib/rack/etag.rb:56:in
rack (1.3.4) lib/rack/etag.rb:26:in
actionpack (3.1.1) lib/action_dispatch/middleware/head.rb:14:in
Any idea on how to implement massive destroy function?
like checkboxes in front of each entry an a massive destroy button?
Nice Railscast anyway.
That totally exists now. They're called Batch Actions :]
Very!, Very! Nice =)
it's like they said, i've been working with this gem and one advice, if you have to customize too much your admin don't use this gem, it depends on formtastic and metasearch, which gives a lot of work to understand how works and make simple things in rails very complicated.
use just for simple projects.
So I see lots of people asking about roles and limiting what a specific user can see. Has anyone found a way to do this with active admin? At this point I'm not sure it's easily done.
Can I integrate ActiveAdmin in views/layout/application.html.erb
<title> .... </title>
Does ActiveAdmin supports sorting through a belongs_to column?
Kind of. It will sort by the ids of the parent model, instead of something more useful (like alphabetical sorting).
Does someone of you use this gem and has custom validations in a model?
I have something like this, but ActiveAdmin ignores it.
self.errors[:base] << "My error message" if my_validation(self.id) == true
Perhaps because you're not using the add function? The below format works fine for me.
errors.add(:name, 'Try again!') unless is_cool?(name)
How I can Replace ActiveAdmin Default (login)Page Into my own Customize Login Page.Plz help?
The simplest method is to copy the app/views/active_admin/devise/sessions/new.html.erb file (you can find it here https://github.com/gregbell/active_admin/blob/master/app/views/active_admin/devise/sessions/new.html.erb) to your application directory, then just make any changes that you might need.
Internally, active admin uses devise, so you can go as far as just doing away with active admin's devise config, by replacing the following code in your routes.rb file.
# devise_for :admin_users, ActiveAdmin::Devise.config
And updating config/initializers/active_admin as you see fit.
i'm using ActiveAdmin in my application. Reached to the dashboard page but when i have run "rails g active_admin:resource product" command, after that server is not running. I'm using Rails 3.2, Ruby 1.9.2. Can somebody help me... Thanks
/home/ali/MySite/app/admin/products.rb:1:in ': uninitialized constant Product (NameError) from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:161:inblock in load!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:161:in each' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:161:inload!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:187:in routes' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin.rb:78:inroutes' from /home/ali/MySite/config/routes.rb:2:in block in ' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:ininstance_exec' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in eval_block' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:indraw' from /home/ali/MySite/config/routes.rb:1:in ' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:inblock in load_paths' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in each' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:inload_paths' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:in reload!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:108:inreload_routes!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/reloader.rb:34:in reload!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/reloader.rb:61:inblock in attach!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:429:in _run1902147173993390372prepare4025180163458367323callbacks' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in__run_callback' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in _run_prepare_callbacks' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:inrun_callbacks' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:74:in prepare!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:48:inprepare!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/finisher.rb:47:in block in module:Finisher' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:ininstance_exec' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in run' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:55:inblock in run_initializers' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in each' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:inrun_initializers' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:136:in initialize!' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:inmethod_missing' from /home/ali/MySite/config/environment.rb:5:in ' from /home/ali/MySite/config.ru:4:inblock in ' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:in instance_eval' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:ininitialize' from /home/ali/MySite/config.ru:1:in new' from /home/ali/MySite/config.ru:1:in' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:in eval' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:inparse_file' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:200:in app' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:46:inapp' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:301:in wrapped_app' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:252:instart' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in start' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:55:inblock in ' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in tap' from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in' from script/rails:6:in require' from script/rails:6:in'
same for me , can anyone help?
The command rails g active_admin:resource product doesn't actually create a model; it just creates the app/admin/products.rb file so Active Admin renders a GUI for this resource when you start your server. You've got to run rails g model product first.
rails g active_admin:resource product
rails g model product
Ryan -- I'm a big fan of this site, as you know from our email exchanges. So, I offer some friendly feedback from a moderate level Rails developer.
This cast was a nightmare to undo. I hod neither an idea about the dependency on Devise, nor the initializers the install method creates.
As you already know, you have a huge middle (moderate level) dev community you could reach. I'id personally pay almost anything to have things casted at my level.
The Bell Curve of Rails development reaches people like me -- and you should tap the market that is most willing to pay.
I know you are hesitant to recommend best-practices as to not divide the Rails community. I certainly respect that.
But the fact remains that every industry has its best practices, and I wish your and your cohorts could standardize on some so that your casts evolve from those best practices In my view, these casts are the means to an end, and we all want to reach the end.
Nonetheless, keep keep up the excellent work independent of my daft request.
Kind Regards, Hunt
Ryan, or anybody who can help :)
i'm planning to use active admin for my website. For some forms, i want to initialize its field assigned with its user information.
For example I have 3 tables, admin_users, agents, packets, admin_users has_one agents, and agents has_many. In Packet new form, i want to assign agent_id field with current agent.
I've been trying to assign before_create in packet model but none is work. So how can I assign value before showing create page?
Assigning before_create (etc) callbacks in your model work just fine with ActiveAdmin. What exactly is your problem?
i have an existing app with sqlite database and i want to create a new app only for active admin.
can i use the database from the first app?
if yes, can you show me how to do it?
I have recently created plugin for AA, which helps to easy and dynamicly change sidebar position to left or right. I put sources here https://github.com/Fivell/active_admin_sidebar
Hey does anyone know how to show the selection toggle next to each row for batch actions when using the custom table columns.
This is there by default but disappears as soon as we customize. I'm not able to find it in the documentation.
Found it selectable_column inside the index do block
thank you for the great screencast.
It would be nice if you make another screencast on active_admin on some advanced topics like file uploads and integration with globalize3.
I'm new to ruby on rails so forgive me. How does active admin know where your products are and how does it pull them in? I see after you setup active admin the products were already in there.
After doing everything that is said in this tutorial, and after running the rake db:migrate command, I get an error that says:
NoMethodError in Active_admin/devise/sessions#new
/var/lib/gems/1.9.1/gems/activeadmin0.5.1/app/views/active_admin**/devise/sessions/new.html.erb where line #7 raised:
undefined method `username' for #AdminUser:0xa2ccb6c
I am new to rails, and not sure how to solve this. Any help is appreciated.
please provide solution as early as possible
ArgumentError in Active_admin/devise/sessions#new
Showing C:/Ruby193/lib/ruby/gems/1.9.1/gems/activeadmin-0.6.0/app/views/layouts/active_admin_logged_out.html.erb where line #9 raised:
different prefix: "C:/" and "G:/rails_workspace/newWorkspace/myActAdmin/app/assets/stylesheets"
How do we write a simple ruby code that should run on index page despite of its scopes, it should just run,i know its too lame to ask, but dint find anywhere :( do help ..actually i wnat to save a value in session variable , but the session value is set when scope returns some records else it doesnt
ActiveAdmin helped us get up and running quickly, but once we had use cases outside of very simple CRUD, it became nightmarish.
Do read this: http://staal.io/blog/2013/02/26/mastering-activeadmin/
I did try rails_admin first because it seemed more customizable but it didn't have all the features I wanted
Seems line image attachments is a bit undercooked in active admin. Any examples of a good way to to it, including deleting & preview.
Currently im using paperclip & editing the form like this:
:as => :file,
:hint => f.template.image_tag(f.object.image.url(:medium))
I could keep going and add some JS and a delete button, but it seems like something the framework should administer
When creating a new product in this example, released at Date comes with four fields. How do I format to get only one input field for date. I do not need the time
I'm getting a Session Error. From what i read this is a problem with simple_from and Active Admin.. Is there any Solution ?
If anyone is interested in a WYSIWYG editor compatible with activeadmin, check out https://github.com/stefanoverna/activeadmin-wysihtml5, is extremely good!
I didn't see any documentation on how to tweak controllers. Where might I be able to find something like that? for instance, redirecting to a different route.
Does anyone know of a tutorial that is more up-to-date with Rails 4. I'm having problems figuring out how to a simple CRUD with the strong parameters.
I want to save the filters params , that applied on a model. How can i get these params. Do anyone have any idea about this.