activeadmin

How to add Colorpicker in Rails Active Admin?

一笑奈何 提交于 2021-02-10 08:41:28
问题 I want to implement this http://www.eyecon.ro/colorpicker/#about or any other color picker in one of the Active Admin form. Any help is appreaciated. Thanks, GS 回答1: The quickest way to get that working is simply add a class to your input using the input_html options. f.input :color, input_html: { class: 'colorpicker' } And then in active_admin.js.coffee , add in the code to turn .colorpicker input fields into color pickers. If you are going to be making a lot of them, or adding options to

ActiveAdmin has_many form not saved if parent model is new and is NOT NULL in child model

十年热恋 提交于 2021-02-07 18:32:36
问题 I have two models, Room and Student . Room has_many Student s. Student belongs_to Room . I got an error Room can't be blank when I try to add Student to Room during creating a new Room. My guess is that, upon submission, child object (student) is saved before parent object (room) is saved. Is there a way to bypass the order without remove the NOT NULL setting on room_id? Or my guess is wrong? Or even worse, I am doing it wrong? # app/models/room.rb class Room < ActiveRecord::Base validates

Rails ActiveAdmin: showing table of a related resource in the same view

我们两清 提交于 2021-02-05 20:30:31
问题 When show ing a resource using the Rails ActiveAdmin gem, I want to show a table of another associated model. So let's say a Winery has_many :products . Now I want to show the products associated on the show page of the Winery admin resource. And I want that to be a table similar to what I would get on the index of the Products resource. I got it to work, but only by recreating the HTML structure manually, which kind of sucks. Is there a cleaner way to create an index table style view for a

Set Multi Tenant in Active Admin Controllers (required for Searchkick index)

五迷三道 提交于 2021-01-29 09:11:41
问题 I am using Active Admin in my multi tenant app. I also use Searchkick which has a custom tenant specific index in each model: class Budget < ApplicationRecord multi_tenant :company searchkick inheritance: true,index_name: -> { [MultiTenant.current_tenant.tenant_name, model_name.plural, Rails.env].join('_') } end The issue is that in AA this logic fails because on the tenant is set. I want to be able to set this in AA when updating a record. For example I would update http://localhost:4000

Customising ActiveAdmin CSV

杀马特。学长 韩版系。学妹 提交于 2021-01-29 07:34:44
问题 I am using Activeadmin and would like to export the associated model values in the same CSV file. I am able to get the result but its not in a proper format. I want all the question to be the column name and the answer for that to be displayed in the row. can anyone help me? Papplication.rb ActiveAdmin.register Papplication do csv do column "Questions" do |papp| @questions.map do |question| question.question_text end end column "Answers" do |papp| @questions = Question.where(:program_id=>papp

Breadcrumbs list in ActiveAdmin shows wrong name when using friendly_id

☆樱花仙子☆ 提交于 2021-01-01 07:14:17
问题 I have a model named Company that has code . The column is used for friendly_id . class Company < ActiveRecord::Base extend FriendlyId friendly_id :code, use: :slugged end ActiveAdmin doesn't recognize friendly_id , so that I had to override find_resource method like this: ActiveAdmin.register Company do controller do def find_resource scoped_collection.friendly.find(params[:id]) end end end With this code I can edit the model attributes by ActiveAdmin, but breadcrumbs list in edit page shows

Breadcrumbs list in ActiveAdmin shows wrong name when using friendly_id

妖精的绣舞 提交于 2021-01-01 07:13:52
问题 I have a model named Company that has code . The column is used for friendly_id . class Company < ActiveRecord::Base extend FriendlyId friendly_id :code, use: :slugged end ActiveAdmin doesn't recognize friendly_id , so that I had to override find_resource method like this: ActiveAdmin.register Company do controller do def find_resource scoped_collection.friendly.find(params[:id]) end end end With this code I can edit the model attributes by ActiveAdmin, but breadcrumbs list in edit page shows

How can I use action text on active admin

匆匆过客 提交于 2020-12-29 12:08:49
问题 i'm using rails 6.0.0 and ruby 2.6.0, I want to know what's the best way to use ActionText in ActiveAdmin, should I have to use render? 回答1: I used this f.rich_text_area :content inside ActiveAdmin but it didn't work for me so I added <trix-editor> tag inside a custom form following this Form Partial Tricks but also this didn't work so I ended up using this gem ActiveAdmin Quill Editor it was easy to setup and worked perfectly Install Add this to your Gemfile gem 'activeadmin_quill_editor' in

How can I use action text on active admin

时间秒杀一切 提交于 2020-12-29 12:00:50
问题 i'm using rails 6.0.0 and ruby 2.6.0, I want to know what's the best way to use ActionText in ActiveAdmin, should I have to use render? 回答1: I used this f.rich_text_area :content inside ActiveAdmin but it didn't work for me so I added <trix-editor> tag inside a custom form following this Form Partial Tricks but also this didn't work so I ended up using this gem ActiveAdmin Quill Editor it was easy to setup and worked perfectly Install Add this to your Gemfile gem 'activeadmin_quill_editor' in

How can I use action text on active admin

浪尽此生 提交于 2020-12-29 11:58:32
问题 i'm using rails 6.0.0 and ruby 2.6.0, I want to know what's the best way to use ActionText in ActiveAdmin, should I have to use render? 回答1: I used this f.rich_text_area :content inside ActiveAdmin but it didn't work for me so I added <trix-editor> tag inside a custom form following this Form Partial Tricks but also this didn't work so I ended up using this gem ActiveAdmin Quill Editor it was easy to setup and worked perfectly Install Add this to your Gemfile gem 'activeadmin_quill_editor' in