Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby ActiveAdmin用户显示错误_Ruby_Ruby On Rails 4_Activeadmin - Fatal编程技术网

Ruby ActiveAdmin用户显示错误

Ruby ActiveAdmin用户显示错误,ruby,ruby-on-rails-4,activeadmin,Ruby,Ruby On Rails 4,Activeadmin,我使用ActiveAdmin,我有项目和任务。创建新任务时,管理员用户下拉列表显示为#管理员用户:0x007fbe6d74deb0。朋友们,如何修复它?我想简单地显示用户的电子邮件 Rails 4.1.0 ActiveAdmin 1.0.0 ruby 2.1 app/admin/task.rb ActiveAdmin.register Task do scope :all, :default => true # Defines the default scope,

我使用ActiveAdmin,我有项目和任务。创建新任务时,管理员用户下拉列表显示为#管理员用户:0x007fbe6d74deb0。朋友们,如何修复它?我想简单地显示用户的电子邮件


Rails 4.1.0

ActiveAdmin 1.0.0

ruby 2.1


app/admin/task.rb

ActiveAdmin.register Task do

    scope :all, :default => true      # Defines the default scope, showing all rows 
    scope :due_this_week do |tasks|   # 
      tasks.where('due_date > ? and due_date < ?', Time.now, 1.week.from_now)
    end
    scope :late do |tasks|
      tasks.where('due_date < ?', Time.now)
    end
    scope :mine do |tasks|
      tasks.where(:admin_user_id => current_admin_user.id)
    end

    show do
      panel "Task Details" do
        attributes_table_for task do
          row("Status") { status_tag (task.is_done ? "Done" : "Pending"), (task.is_done ? :ok : :error) }
          row("Title") { task.title }
          row("Project") { link_to task.project.title, admin_project_path(task.project) }
          row("Assigned To") { link_to task.admin_user.email, admin_admin_user_path(task.admin_user) }
          row("Due Date") { task.due_date? ? l(task.due_date, :format => :long) : '-' } 
        end
      end

      active_admin_comments # Provides a simple commenting system for each model. Enabled it here because commenting on a task could be very useful to discuss functionality, or something similar.
    end

    # Creates a sidebar panel, titled “Other Tasks For This User”, which is shown only on the “show” page. 
    # It will show a table for the currentadminuser, and all tasks where the project is the same as the project being shown.

    sidebar "Other Tasks For This User", :only => :show do
      table_for current_admin_user.tasks.where(:project_id => task.project) do |t|
        t.column("Status") { |task| status_tag (task.is_done ? "Done" : "Pending"), (task.is_done ? :ok : :error) }
        t.column("Title") { |task| link_to task.title, admin_task_path(task) }
      end
    end

    permit_params :title, :project_id, :admin_user_id, :due_date, :is_done

  # See permitted parameters documentation:
  # https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
  #
  # permit_params :list, :of, :attributes, :on, :model
  #
  # or
  #
  # permit_params do
  #  permitted = [:permitted, :attributes]
  #  permitted << :other if resource.something?
  #  permitted
  # end

end
ActiveAdmin.register任务do
scope:all,:default=>true#定义默认范围,显示所有行
范围:本周到期做任务
任务。其中('due_date>?和due_date<?',Time.now,1.week.from_now)
结束
范围:后期任务|
任务。其中('到期日<?',时间.现在)
结束
经营范围:矿山do |任务|
tasks.where(:admin\u user\u id=>current\u admin\u user.id)
结束
表演
“任务详细信息”面板
任务do的属性\u表\u
行(“状态”){Status_标记(task.is_done?:“done”:“Pending”),(task.is_done?:ok::error)}
行(“标题”){task.Title}
行(“项目”){link_to task.Project.title,admin_Project_path(task.Project)}
行(“分配给”){link_To task.admin_user.email,admin_admin_user_path(task.admin_user)}
行(“到期日”){task.Due_Date??l(task.Due_Date,:format=>:long):'-'}
结束
结束
active_admin_comments为每个模型提供了一个简单的评论系统。之所以在这里启用它,是因为对任务进行评论对于讨论功能或类似内容非常有用。
结束
#创建标题为“此用户的其他任务”的侧栏面板,该面板仅显示在“显示”页面上。
#它将为currentadminuser显示一个表,以及项目与所显示项目相同的所有任务。
侧栏“此用户的其他任务”,:only=>:show do
表_用于当前_admin_user.tasks.where(:project_id=>task.project)do | t|
t、 列(“状态”){task | Status|u标记(task.is_done?“done”:“Pending”),(task.is_done?:ok::error)}
t、 列(“标题”){| task | link_to task.Title,admin_task_path(task)}
结束
结束
许可证参数:标题,:项目id,:管理员用户id,:到期日,:完成了吗
#参见许可参数文档:
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-建立强参数
#
#允许参数:列表,:的,:属性,:打开,:模型
#
#或
#
#许可证
#允许=[:允许,:属性]
#允许您的对象(
AdminUser
)应实现以下方法之一:


(摘自)

有效!我为我的管理员用户实现了一个:to_s,现在一切正常,非常感谢,伙计;)
# Active Admin makes educated guesses when displaying objects, this is
# the list of methods it tries calling in order
setting :display_name_methods, [ :display_name,
                                  :full_name,
                                  :name,
                                  :username,
                                  :login,
                                  :title,
                                  :email,
                                  :to_s ]