activeadmin

Adding Numeric Range Filtering to ActiveAdmin

为君一笑 提交于 2019-12-13 15:33:34
问题 Greetings and Happy Holidays 2015 -- I tried to add numeric range filtering per the excellent blog post by Boris Stall. I'm running: Rails 4.2.4 Ruby 2.2.3 ActiveAdmin 1.0.0pre2 I keep running into this error: Unable to find input class NumericRangeInput Here is my config/initializers/active_admin/filter_numeric_range_input.rb module ActiveAdmin module Inputs class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput # Add filter module wrapper include ActiveAdmin::Inputs::Filters:

Devise, Rolify and Cancan to ActiveAdmin

半城伤御伤魂 提交于 2019-12-13 12:27:57
问题 I am developing an app using Devise, Rolify and CanCan. Can I shift it completely to be administered by ActiveAdmin. Is there any documentation for that? 回答1: I know it's been a while since the question was asked... but as I found it while doing a google search, I think I can post an answer to help others. So! There is a documentation to make ActiveAdmin use Cancan for its authentication and authorization system. Here is a very simple how to add a CancanAdapter in ActiveAdmin In fact they

Nested form in Active Admin

青春壹個敷衍的年華 提交于 2019-12-13 05:21:01
问题 I need help! I have 2 models for a Survey: class Poll < ActiveRecord::Base has_many :poll_questions, :dependent => :destroy accepts_nested_attributes_for :poll_questions, :reject_if => lambda { |a| a[:text].blank? }, :allow_destroy => true end There is model for questions as follows: (it seems these assocciations are correct) class PollQuestion < ActiveRecord::Base belongs_to :poll has_many :poll_answers, :dependent => :destroy accepts_nested_attributes_for :poll_answers, :reject_if => lambda

Editing a has_one association in ActiveAdmin - destroying when attribute is blanked

℡╲_俬逩灬. 提交于 2019-12-13 05:13:05
问题 I've got a model in which a very small percentage of the objects will have a rather large descriptive text. Trying to keep my database somewhat normalized, I wanted to extract this descriptive text to a separate model, but I'm having trouble creating a sensible workflow in ActiveAdmin. My models look like this: class Person < ActiveRecord::Base has_one :long_description accepts_nested_attributes_for :long_description, reject_if: proc { |attrs| attrs['text'].blank? } end class LongDescription

Active Admin before filter for namespace only

我与影子孤独终老i 提交于 2019-12-13 04:35:45
问题 I have a namespace admin . I would like to apply a before_filter only to this namespace (not the default one, which is superuser ). I can add the following code in active_admin.rb ns.before_filter :is_subscribed? But then, the superuser gets the filter too. I tried adding the before_filter inside my namespace configuration : config.namespace :admin do |ns| ... ns.before_filter :is_subscribed? end but Rails throws an error : undefined method `before_filter' for #<ActiveAdmin::Namespace

How to reset user´s password by Devise authentication token directly from edit_page in Active Admin?

半世苍凉 提交于 2019-12-13 03:45:58
问题 I would like the admin_user to be able to reset user´s password from Active Admin edit_page, but am currently stuck. My idea was to make an action_item button and launch @user.send_reset_password_instructions method from devise authentication gem for a users object which works. But, action_item cannot get any notice: message and that´s where I´m stuck. Can you please help me implement the action_item button which could launch the @user.send_reset_password_instructions, redirect to the same

Rails activeadmin/carrierwave has_many photos relationship throwing mass-assignment exception

China☆狼群 提交于 2019-12-13 02:56:14
问题 I have a model BlogPost defined as class BlogPost < ActiveRecord::Base attr_accessible :title, :body, :photo, :photos_attributes, as: :admin has_many :photos, class_name: 'BlogPhoto', dependent: :destroy validates :body, :photo, :title, presence: true validates :title, uniqueness: true accepts_nested_attributes_for :photos, allow_destroy: true end from schema create_table "blog_posts", :force => true do |t| t.string "title" t.text "body" t.datetime "created_at", :null => false t.string "photo

has_many association sate check executing N+1 queries active admin

旧巷老猫 提交于 2019-12-13 02:49:39
问题 Model Strucure: User has many subscriptions and blogs , Subscriptions has_many coupons. I have included the has_many table but i need to perform state check for every subscription So if i perform where query in scoped collection than it gets all the user only having valid subscriptions. So how to avoid N+1 query and also perform state check. def scoped_collection end_of_association_chain.includes(:subscriptions, :blogs) end index do column :email column "referrer" do |user| subscription =

How to hide input on conditions in Formtastic?

和自甴很熟 提交于 2019-12-13 00:55:31
问题 I inherited a project that is using ActiveAdmin with Formtastic in Rails. I have very little experience with either of these, but it seems simple enough to do simple tasks. So, I have been tasked with adding a radio input, but hides the another input if the radio doesn't match a certain value. I've search everywhere and can't seem to find anything on this. Here is my form: form do |f| f.inputs 'Book Details' do f.input :name, required: true f.input :has_subtitle, as: radio, required: true f

Active Admin -refresh second drop down based on choice on first drop down (Rails 3.2)

风流意气都作罢 提交于 2019-12-12 13:25:58
问题 I'm having trouble implementing a form on active admin where the second dropdown (subcategory) has to adjust to the category choice on the drop down that precedes it. Basically I want to first set a industry for a company then select among sub-industry drop down. I have created 2 models: CompanySector CompanySubsector For practical reasons, I use the words 'sector' and 'subsectors' in the code. I am trying to use @okliv suggestions on Active Admin - refresh second drop down based on first