activeadmin

Can you disable Pundit with Devise and Active Admin?

百般思念 提交于 2019-12-12 02:28:00
问题 I have an existing Rails app that has Devise / Pundit running on the User model. I have followed: How to get Active Admin to work with Pundit after login https://gist.github.com/tomchentw/8579571 I don't need authorization right now - Devise for authentication will do. Can I just "turn off" Pundit for Active Admin? UPDATE This is super monkey patch: after_action :verify_policy_scoped, only: [:index] if controller_path.split('/').first == "admin" It works but I don't think it's ideal. 回答1:

ActiveAdmin: Update another model after create/update

天大地大妈咪最大 提交于 2019-12-12 01:40:32
问题 So what I am trying to do is this. I currently have a piece of equipment that has many parts on it. I also have an inventory of parts. What I am looking to do is when you add a part to the equipment, it removes it from the inventory. I currently have the parts attaching to the equipment but not sure how to decrease the quantity. Here are the admin models for part and equipment. equipment.rb ActiveAdmin.register Equipment do permit_params :name, :description, :status, :manufacturer_id, :serial

Update massive number of rows of associated objects in has_many/belong_to relations (Rails 4, postgresql 9.4, activeadmin)

若如初见. 提交于 2019-12-11 21:15:45
问题 When creating a model Deal, I use an after_create to create prizes on the DealPrize table. Deal and DealPrize have a belong to/has_many relations: a Deal has many Deal prizes and a Dealprize belongs to a Deal. It works like this: on my admin panel (using activeadmin), inside a Deal, I have a column 'prize-number' and I use an after_create so that every time the admin creates a new deal, the app takes this prize_number column, and create this volume of prizes (inserting as many rows as

Unable to install activerecord in Ruby on Rails 4.1.4

╄→尐↘猪︶ㄣ 提交于 2019-12-11 20:10:24
问题 I am unable to install activerecord in Ruby on Rails 4.1.4. I've added gem 'activeadmin', github: 'activeadmin' to the end of Gemfile and run bundle install . It returns 0, so I've tried to run rails g active_admin:install command, but it returns the following error: NameError: undefined local variable or method install' for main:Object from (irb):3 from E:/software/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in start' from E:/software/Ruby200-x64/lib

Dynamically-adjusting drop down fields on Active Admin form (rails 3.2)

谁说胖子不能爱 提交于 2019-12-11 20:07:42
问题 I have a very basic architecture on my Ruby on Rails app: a company model a Industry model (a company belongs to an industry) a Sub-industry model (a subindustry belongs to a Industry) On my active admin form page, I want to put fields so that for each company, I first select in a drop down the industry it belongs to (this works so far), and then another field "sub industry", that would ONLY display, according to the industry I selected in the previous field, the subindustries that I have

Rails 4.2 ActiveAdmin 1.0.0.pre2 Cannot create a AdminUser due to duplicate key value violates unique constraint "index_admin_users_on_email

时光毁灭记忆、已成空白 提交于 2019-12-11 19:41:27
问题 Hi i am having a hard time figuring out this error. Yesterday i posted a question that my AcitveAdmin email field is always empty.Today i realised the problem is a bit bigger. When i try to add a new user in the rails console the following happens. >> au = AdminUser.new(email: 'sample@tom.com', password: "123456789", password_confirmation: "123456789") => #<AdminUser id: nil, email: "", encrypted_password: "$2a$10$Xt6EpJhtQ3d1v62KNZFUk.oi1RYe2gEBBeWVd/vApvi...",reset_password_token: nil,

collection_select within activeadmin

喜夏-厌秋 提交于 2019-12-11 18:43:30
问题 Activeadmin creates a nice dropdown menu for has_many & belongs_to associations. But since I needed to edit my form, these things where deleted. In my original form, I used: <%= f.label :artist_id %><br /> <%= collection_select(:work, :artist_id, Artist.all, :id, :name) %> But this does not work in my admin/works.rb. The form i have created there is: ActiveAdmin.register Work do form do |f| f.inputs "Details" do f.input :title f.input :exhibition_id f.input :artist_id f.input :photo end f

Delete faster 300K associated objects on activeadmin (Rails 4, Activeadmin)

笑着哭i 提交于 2019-12-11 14:54:21
问题 When creating a model Deal, I use an after_create to create prizes on the DealPrize table. Deal and DealPrize have a belong to/has_many relations: a Deal has many Deal prizes and a Dealprize belongs to a Deal. It works like this: inside Deal, I have a column 'prize-number' and I use an after_create so that every time the admin creates a new deal, the app takes this prize_number column, and create this volume of prizes (inserting as many rows as necessary=> often more than 300,000) inside the

activeadmin custom render if

浪尽此生 提交于 2019-12-11 14:10:00
问题 My below code ActiveAdmin.register Question do belongs_to :topic, :optional => true controller do def index @topic = Topic.find_by_id params[:topic_id] if @topic @questions = @topic.questions render 'settings/questions/_by_admin', :layout => 'active_admin' return end end end end is throwing NoMethodError in Admin/questions#index Showing /home/amol/.rvm/gems/ruby-1.9.2-p290@xxx/gems/activeadmin-0.5.0/app/views/layouts/active_admin.html.arb where line #1 raised: undefined method `base' for nil

Switching Apartment tenants in Active Admin

依然范特西╮ 提交于 2019-12-11 10:37:49
问题 This is an extension of my previous post: Active Admin and the Apartment Gem I thought I had this working but I am stuck. I have a Company model in the public schema as the tenant model and Locations in individual tenants. Here is my Active Admin location.rb file: ActiveAdmin.register Location do #Apartment::Tenant.switch!('abc') controller do #Apartment::Tenant.switch!('abc') before_filter do Apartment::Tenant.switch!('abc') skip_authorization skip_policy_scope end end end The skip