activeadmin

How do I use instance variables, defined in the controller, in the view with ActiveAdmin?

左心房为你撑大大i 提交于 2019-12-12 08:01:14
问题 I have this: ActiveAdmin.register User do controller do def show @user = User.find(params[:id]) show! end end show do attributes_table do row "User" do link_to @user.display_name, user_path(@user.slug) end end end end But when I load the page, I get an error saying: undefined method `display_name' for nil:NilClass which means that @user is nil. I am positive that @user is set appropriately (meaning the finder is getting appropriate data that exists in the db). I'm thinking it has something to

ActiveAdmin: sort by child association's property

南笙酒味 提交于 2019-12-12 07:46:40
问题 I am having these objects: class District < ActiveRecord::Base belongs_to :city end class City < ActiveRecord::Base has_many :districts end What I would like to do (and been unable to do so thus far), is: have a City column in District 's index and that column should be sortable on City.name . Closest thing I was able to do without crashing ActiveAdmin is: index do column City.human_name(:count => :other), :city, :sortable => :city_id end Which of course is not good enough; I don't want to

activeadmin: adding delete for a nested resource

别等时光非礼了梦想. 提交于 2019-12-12 07:39:56
问题 I have a infrastructure object composed for many datacenters. In the apps/admin/infrastructures.rb I have the following code: form do |f| f.inputs "Infrastructure details" do f.input :name f.has_many :datacenters do |datacenter_form| datacenter_form.input :name end end f.buttons end I can add datacenters with no problems but I don't know how I can delete it from infrastructure form. 回答1: Sep 2017 Update: Rails 5.1.4, ActiveAdmin 1.0.0 Append :id and _destroy in permit_params along with other

ActiveAdmin not saving has_many nested object

南笙酒味 提交于 2019-12-12 06:25:25
问题 I cannot seem to find out why my has_many record will not save. I've test with has_one in the models and it works fine but when I change it to has_many it doesn't work. I've check a few simular stackoverflow posts and I seem to have this correct but it doesn't work. Nested form in activeadmin not saving updates & ActiveAdmin Form not saving nested object This is for Rails version 5.1.0.alpha and Activeadmin version 1.0.0.pre4 I do not get any errors nor do I see the nested object get created

Logout from ActiveAdmin destroy other sessions

被刻印的时光 ゝ 提交于 2019-12-12 06:23:57
问题 I am using devise with activeadmin and one other model. If I open both interfaces on browser and logout from one it will also destroy other sessions. Started GET "/admin/logout" for 127.0.0.1 at 2015-11-03 19:45:25 +0500 Processing by ActiveAdmin::Devise::SessionsController#destroy as HTML Parameters: {"authenticity_token"=>"6rqzYcjQNgm8sOcAy2ItHvqGWTYyUBEK2tE+hJi8Ti0E25qJLR+vdA9W++HHtFaD3CpBtnNAn6xbhS6mr8YLTQ=="} Teacher Load (30.4ms) SELECT `teachers`.* FROM `teachers` WHERE `teachers`.`id`

After adding controller in active admin resource , validations error cannot be shown

本小妞迷上赌 提交于 2019-12-12 05:08:14
问题 Previously i have form and show method in active admin resource. At that time validation errors shown in forms. But now i have to write controller in resource , after adding no more validation errors. Am i doing something wrong. Below is my code. ActiveAdmin.register PsychographicsQuestion do config.clear_action_items! permit_params :id , :title,:psychographics_question_type ,:expiry_date , :_destroy , psychographics_options_attributes: [:id,:title , :_destroy] form do |f| f.semantic_errors

no implicit conversion of ActiveSupport::SafeBuffer into Integer

天涯浪子 提交于 2019-12-12 04:51:52
问题 Here is my partial _new_post.html.haml : = semantic_form_for Post.new, as: :post, url: client_panel_discussion_posts_path(resource), html: { data: { discussion_posts_url: client_panel_active_submission_discussion_url(resource.client_application, id: resource.slug) }, multipart: true}, builder: ActiveAdmin::FormBuilder, remote: true, method: :post do |f| =f.inputs do =f.input :body =f.has_many :attachments do |a| =a.input :s3_url, as: :hidden, input_html: { class: "s3_url" } =a.s3_file_field

Set ActiveAdmin filter default value

跟風遠走 提交于 2019-12-12 04:46:41
问题 I have a simple filter in ActiveAdmin for boolean value. It looks like this filter :invisible, as: :select You may choose "any", "true" or "false" and it works just fine. But the default value of the filter is "any", while I need to set it to "true". How can I do it? Thank you. 回答1: try some like this : filter : invisible, as: :select, collection: [["Yes", true], ["No", false]] This works fine for me. Obviously you can edit the "Yes" - "No" string as you want. 回答2: I've found an answer. You

Cannot build nested polymorphic associations'. Are you trying to build a polymorphic one-to-one association

浪尽此生 提交于 2019-12-12 03:53:24
问题 I have had a similar situation where i had Activities which has one Task which has one taskable and building the task would also build the taskable, like so: def new @activity = Activity.new @activity.task = @activity.build_task end Now i have Terms which have many TermTranslations which have many attachments which have an attachable (Image or Audio) but line 18 @term = Term.new(permitted_params[:term]) of admin/term.rb i get this error: Cannot build association `attachable'. Are you trying

Matrix Edit in rails ActiveAdmin?

家住魔仙堡 提交于 2019-12-12 02:35:20
问题 I'm using ActiveAdmin in Rails. My use case is similar to currency-exchange: say I have 10 currencies, and one currency can be converted into another one. In order to support editing, I need to create a matrix, where rows is CurrencyA, and columns is CurrencyB, and the value is conversion from CurrencyA to CurrencyB, something like this: | | SGD | USD | HKD | CNY | |-----|-----|-----|-----|-----| | SGD | | | | | | USD | | | | | | HKD | | | | | | CNY | | | | | Correspondingly, in my database,