标签: activeadmin

Rails 3.1 + ActiveAdmin GEM css/stylesheet冲突?

我必须遗漏一些非常简单的东西,但我找不到其他人的问题.基本上,Rails 3.1将所有.css文件合并到application.css中.安装ActiveAdmin后,ActiveAdmin的CSS也合并到application.css中,导致冲突并覆盖我的样式表.

我在这里错过了什么?

ruby-on-rails-3 activeadmin

4
推荐指数
1
解决办法
1023
查看次数

主动管理员更改默认模型admin_user

我正在使用Active Admin开始我的第一个项目.要为我的用户使用其他模型,请使用以下命令:

rails generate active_admin:install User
Run Code Online (Sandbox Code Playgroud)

在此之后,我在active_admin初始化程序中进行了此更改:

config.authentication_method = :authenticate_user!
config.current_user_method = :current_user
Run Code Online (Sandbox Code Playgroud)

我正确登录我的应用程序,但在主页上我收到此错误:

undefined method `destroy_admin_user_session_path' for #<ActiveAdmin::Views::HeaderRenderer:0x007ff8fa086a60>
Run Code Online (Sandbox Code Playgroud)

我该如何正确修理?

ruby-on-rails-3 activeadmin

4
推荐指数
1
解决办法
2366
查看次数

Active Admin中的自定义表单

我在Active Admin 0.5中创建自定义表单.我已经注册了一个页面并通过DSL创建了一个表单:

ActiveAdmin.register_page 'Planning', :namespace => :pos_admin do

  content :title => proc{ I18n.t("active_admin.dashboard") } do

    form do |f|
      f.input :type => :text
      f.input :type => :submit
    end

  end
end
Run Code Online (Sandbox Code Playgroud)

问题是,在提交表单时,我得到一个空的Params哈希.表单标记不包含真实性标记.

我究竟做错了什么?

ruby-on-rails activeadmin

4
推荐指数
1
解决办法
1万
查看次数

覆盖active_admin form.has_many中的默认范围

给定一个带有__附件的模型Post,附件有一个隐藏的标志.在整个应用程序中,我想轻松地说post.attachments并且只获得可见的,所以我在Attachment模型中设置了一个默认范围(使用squeel):

default_scope -> { where { (hidden != true) | (hidden == nil) } } 
Run Code Online (Sandbox Code Playgroud)

但是管理页面需要能够查看帖子的所有附件,而不仅仅是可见的附件(因此您可以切换隐藏的复选框).执行此操作的默认方式(在admin/posts.rb中)使用default_scope,只允许我编辑可见的:

f.has_many :attachments do |a|
  ...
end
Run Code Online (Sandbox Code Playgroud)

我知道我可以不使用default_scope而是命名它:可见,然后到处(管理页面除外)说post.attachments.visible但我不喜欢这样做.

如何取消管理页面上的子附件?

default-scope ruby-on-rails-3 activeadmin

4
推荐指数
1
解决办法
1009
查看次数

无论如何使用Active Admin添加其他级别的菜单?

我正在使用Active Admin并尝试在下拉菜单中添加其他级别.在文档中,我看到我可以使用此代码放置一个级别:

  ActiveAdmin.register Post do
    menu :parent => "Blog"
  end
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

编辑:

我想要这样的东西:

Menu 1 ^
Menu 2 > Menu A
         Menu B
Menu 3
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails activeadmin

4
推荐指数
1
解决办法
2975
查看次数

Activeadmin自定义操作和表单

我想在我的Users activeadmin页面上实现一个自定义操作(notify_all),单击该页面时将显示一个表单,该表单在提交时将路由到另一个自定义操作(send_notification_to_all).到目前为止,我一直无法使第二部分工作.

管理员/ users.rb的:

ActiveAdmin.register User do

  action_item :only => :index do
    link_to 'Notify All', notify_all_admin_users_path
  end

  collection_action :notify_all, :method => :get do
    puts "notifying...."
    end

  collection_action :send_notification_to_all, :method => :post do
    puts "sending notification...."
  end



end
Run Code Online (Sandbox Code Playgroud)

单击"通知全部"按钮时,将呈现以下视图.意见/管理/用户/ notify_all.html.erb

<form action="send_notification_to_all" method="post">
  <div><textarea rows="10" cols="100" placeholder="Enter message here"></textarea></div>
  <div><input type="submit"></div>
</form>
Run Code Online (Sandbox Code Playgroud)

提交此表单后,我收到401 Unauthorized错误:

Started POST "/admin/users/send_notification_to_all" for 127.0.0.1 at 2014-02-12 14:08:27 -0600
Processing by Admin::UsersController#send_notification_to_all as HTML
WARNING: Can't verify CSRF token authenticity
  AdminUser Load (0.8ms)  SELECT "admin_users".* FROM "admin_users" …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails activeadmin

4
推荐指数
2
解决办法
9455
查看次数

Sprockets :: FileNotFound(用于gem ActiveAdmin)

找不到文件'jquery.ui.datepicker'(在C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/active_admin-f65e7cd6425b/app/assets/javascripts/active_admin/base .js.coffee:2)

认为gem'sprockets'的问题

sprockets (2.11.0) lib/sprockets/context.rb:106:in `resolve'
sprockets (2.11.0) lib/sprockets/context.rb:146:in `require_asset'
sprockets (2.11.0) lib/sprockets/directive_processor.rb:217:in `process_require_directive'
sprockets (2.11.0) lib/sprockets/directive_processor.rb:167:in `block in process_directives'
sprockets (2.11.0) lib/sprockets/directive_processor.rb:165:in `each'
sprockets (2.11.0) lib/sprockets/directive_processor.rb:165:in `process_directives'
sprockets (2.11.0) lib/sprockets/directive_processor.rb:99:in `evaluate'
tilt (1.4.1) lib/tilt/template.rb:103:in `render'
sprockets (2.11.0) lib/sprockets/context.rb:197:in `block in evaluate'
sprockets (2.11.0) lib/sprockets/context.rb:194:in `each'
sprockets (2.11.0) lib/sprockets/context.rb:194:in `evaluate'
sprockets (2.11.0) lib/sprockets/processed_asset.rb:12:in `initialize'
sprockets (2.11.0) lib/sprockets/base.rb:374:in `new'
sprockets (2.11.0) lib/sprockets/base.rb:374:in `block in build_asset'
sprockets (2.11.0) lib/sprockets/base.rb:395:in `circular_call_protection'
sprockets (2.11.0) lib/sprockets/base.rb:373:in `build_asset'
sprockets (2.11.0) lib/sprockets/index.rb:94:in `block in build_asset'
sprockets …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails activeadmin

4
推荐指数
1
解决办法
1491
查看次数

ActiveAdmin复制嵌套表单并删除复选框不起作用

该表单用于向项目添加项目,但项目不会删除!更糟糕的是,任何更新都会复制所有嵌套表单(1x2 = 2,然后下一次更新会为每个更新4等)

应用程序/管理/ project.rb

ActiveAdmin.register Project do

  permit_params  :title, :description, :git_url, :demo_url, :version, :lastpublished, :firstpublished,
   project_features_attributes: [:project_id, :description, :_destroy => true],
   project_mentions_attributes: [:project_id, :title, :url, :published, :_destroy => true]

  form do |f|
    f.semantic_errors *f.object.errors.keys
    f.inputs
    f.buttons
  end

  form do |f|
    f.inputs "Project Details" do
      f.inputs :title
      f.inputs :description
      f.inputs :git_url, :default => "http://github.com/"
      f.inputs :demo_url
      f.inputs :version
      f.inputs :firstpublished
      f.inputs :lastpublished      
      f.inputs do
        f.has_many :project_features,
         :allow_destroy => true,
         :heading => 'Features' do |cf|
              cf.input :description
        end
      end
      f.inputs do …
Run Code Online (Sandbox Code Playgroud)

nested-forms activeadmin ruby-on-rails-4

4
推荐指数
1
解决办法
1495
查看次数

如何在heroku上修复ActionDispatch :: Cookies :: CookieOverflow错误?

我经常ActionDispatch::Cookies::CookieOverflow在我的rails应用程序中遇到heroku错误.我认为在会话中倾倒未使用的信息就像

env["airbrake.error_id"] = notify_airbrake(e)
Run Code Online (Sandbox Code Playgroud)

可能有问题.

我已经在会话中抛出了许多字符串,也许这可能是问题所在.我读了一些帖子,暗示这也可能是因为activeadmin.最后我想创建一个会话表的建议在这里

我无法弄清楚解决这个问题的最佳方法是什么? 请建议所有可能的解决方案

我的config/initializers/session_store.rb中的代码

Demo::Application.config.session_store :cookie_store, key: '_demo_appplication', :domain => :all
Run Code Online (Sandbox Code Playgroud)

通过airbrake我得到这个错误的堆栈跟踪

[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/cookies.rb:471:in []=
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/session/cookie_store.rb:110:in set_cookie
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:350:in commit_session
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:226:in context
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/cookies.rb:560:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/query_cache.rb:36:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in block in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:82:in run_callbacks
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:27:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/remote_ip.rb:76:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in call_app
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in block in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in block in tagged
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:26:in tagged
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in tagged
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/static.rb:64:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/skip_binary.rb:19:in call …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails heroku session-cookies activeadmin

4
推荐指数
1
解决办法
1万
查看次数

两级深度belongs_to关联上的Active Admin过滤器

说一个Person有很多House,House有很多Door.(所以Door有一个house_id和House有一个person_id领域).我在Active Admin中有一个门列表,其中我想要一个允许我选择一个人的过滤器,并向我显示该人所有房屋的所有门.

ActiveAdmin.register Door do
  filter :knob_color
  filter :is_open
  filter :has_window

  filter :house_person      # DOESN'T WORK
  filter :house_person_name # DOESN'T WORK
Run Code Online (Sandbox Code Playgroud)

该Person模型表有一个name领域,所以ActiveAdmin应该能够挑选起来.

我该怎么做呢?

UPDATE

根据要求,我的情况在模型中得到了改变.

# id:   integer
# name: string
class Person < ActiveRecord::Base
  has_many :houses
end

# id:        integer
# person_id: integer
class House < ActiveRecord::Base
  belongs_to :person
  has_many   :doors
end

# id:         integer
# house_id:   integer
# knob_color: string …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails activeadmin

4
推荐指数
1
解决办法
1555
查看次数