ActiveAdmin.register JamRuby::ChatMessage, :as => 'ChatMessage' do
  # Note: a lame thing is it's not obvious how to make it search on email instead of user_id.
  filter :music_session_id
  filter :user_id

  menu :parent => 'Misc'

  config.per_page = 200

  config.sort_order = 'created_at DESC'

  scope("Global", default:true) { |scope|
    scope.where("channel = 'global'")
  }
  scope("Session", ) { |scope|
    scope.where("channel = 'session'")
  }
  index do
    column 'User' do |oo| link_to(oo.user.email, oo.user.admin_url, {:title => oo.user.email}) end
    column "Timestamp" do |post|
      (post.created_at).strftime('%b %d %Y, %H:%M')
    end
    column "Message" do |post|
      post.message
    end
    actions

  end
end
