activeadmin

Use ActiveRecord scope in ActiveAdmin filter

守給你的承諾、 提交于 2020-01-14 14:46:08
问题 In my rails project I have model : class Panel < ActiveRecord::Base has_many :surveys scope :by_survey_name, ->(survey_name) { joins(:surveys).where('surveys.survey_name LIKE (?)', "%#{survey_name}%") } end And the question is how can I use this scope in activeadmin fiter? 回答1: Addd to model: def self.ransackable_scopes(_auth_object = nil) [:by_survey_name] end and then in resource: filter :by_survey_name, as: :string 来源: https://stackoverflow.com/questions/31694398/use-activerecord-scope-in

ActiveAdmin Form not saving nested object

╄→尐↘猪︶ㄣ 提交于 2020-01-14 12:38:19
问题 Using ActiveAdmin with Rails 4, I have two models, Document and Attachment with a one-to-many relationship between them. # models/document.rb class Document < ActiveRecord::Base has_many :attachments accepts_nested_attributes_for :attachments end # models/attachment.rb class Attachment < ActiveRecord::Base belongs_to :document end I registered the models and included permit_params for all the fields in each. Now I used has_many in the form view in the below code. This shows an option to add

ActiveAdmin Form not saving nested object

[亡魂溺海] 提交于 2020-01-14 12:37:08
问题 Using ActiveAdmin with Rails 4, I have two models, Document and Attachment with a one-to-many relationship between them. # models/document.rb class Document < ActiveRecord::Base has_many :attachments accepts_nested_attributes_for :attachments end # models/attachment.rb class Attachment < ActiveRecord::Base belongs_to :document end I registered the models and included permit_params for all the fields in each. Now I used has_many in the form view in the below code. This shows an option to add

ActiveAdmin Batch Action Dynamic Form

霸气de小男生 提交于 2020-01-13 11:04:47
问题 I am using rails 4 with ActiveAdmin. I created a batch action using a custom form to create a Task with a Build number for every selected Device. Here's what my code looks like: ActiveAdmin.register Device do def get_builds builds = [] Build.all.each do |build| builds << [ "[#{build.resource} - #{build.version}] #{build.file_name}", build.id ] end return builds end batch_action :create_task, form: { build: get_builds() } do |ids, inputs| build = Build.find(inputs[:build]) Device.where(id: ids

How to get the current user that is logged in via active admin?

两盒软妹~` 提交于 2020-01-13 07:44:28
问题 I would like to know how to get the current user that is logged in via the active admin GUI? Homepage: http://www.activeadmin.info/ Thanks in advance MODEL admin_user.rb class AdminUser < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model

Can't log into Active Admin. Any way to create an admin user? [closed]

寵の児 提交于 2020-01-12 07:56:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . When I try to log in with the default admin user, I get "invalid email or password." Is there a way to create a user with code and try to log in that way? I can log in on my live website, but not locally. My development code matches exactly what is on production. 回答1: You can run a rails console on your

How to keep DRY with a ActiveAdmin or RailsAdmin, separate from the main application

戏子无情 提交于 2020-01-12 03:30:12
问题 I am building a JSON-only application, it is basically a leaner Rails, with fewer middleware and fewer modules. This is an application being built in Rails 4. I want to to develop a simple app that can administrate the data in the database for the main-app. For this I would like to use Active Admin or Rails Admin. But both options somehow use the underlying models and their validations, requirements and such to build on top of. This means that I need to share at least the models between the

activeadmin heroku stylesheet config issue with partial fix

天涯浪子 提交于 2020-01-11 02:04:27
问题 I was receiving the following error message after precompiling my assets locally and then pushing the code to Heroku: 2012-03-28T17:06:01+00:00 app[web.1]: Started GET "/admin/login" for 67.163.67.203 at 2012-03-28 17:06:01 +0000 2012-03-28T17:06:01+00:00 app[web.1]: 2012-03-28T17:06:01+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: active_admin/mixins. 2012-03-28T17:06:01+00:00 app[web.1]: Load paths: 2012-03-28T17:06:01+00:00 app[web.1]: /app 2012-03

activeadmin heroku stylesheet config issue with partial fix

依然范特西╮ 提交于 2020-01-11 02:04:08
问题 I was receiving the following error message after precompiling my assets locally and then pushing the code to Heroku: 2012-03-28T17:06:01+00:00 app[web.1]: Started GET "/admin/login" for 67.163.67.203 at 2012-03-28 17:06:01 +0000 2012-03-28T17:06:01+00:00 app[web.1]: 2012-03-28T17:06:01+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: active_admin/mixins. 2012-03-28T17:06:01+00:00 app[web.1]: Load paths: 2012-03-28T17:06:01+00:00 app[web.1]: /app 2012-03

Rails ActiveAdmin - change the after update redirect_to

↘锁芯ラ 提交于 2020-01-10 17:39:44
问题 I have a Feature page that belongs to the Car page. That is working exactly how I want to, except for one thing. After creating, updating or destroying, I want the page to be redirected to the admin_car_path(car) instead of the defaults admin_car_feature_path(car,feature) for create and update and admin_car_features_path(car) . I unsuccessfully searched for that. ActiveAdmin.register Car do end ActiveAdmin.register Feature do belongs_to :car end TIA 回答1: Here is the code for update action for