我按照railscast的说明安装activeadmin.安装后,我遇到两个错误 -
1)sign_in的args数量无效 - 所以我将sign_in方法重命名为sign_in_user并解决了这个问题.
然后
2)signed_in的args数无效? - 所以我重命名了我的signed_in?is_signed_in的方法?并解决了这个问题.
现在一切似乎都有效,除非我单击activeadmin中的注销按钮,它表示"已成功注销",但注销按钮仍然位于顶角,并且没有将我注销.
我根据有类似问题的人的建议,将这两件事添加到我的active_admin.rb文件中:
config.logout_link_path = :destroy_admin_user_session_path
Run Code Online (Sandbox Code Playgroud)
和
config.logout_link_method = :delete
Run Code Online (Sandbox Code Playgroud)
但仍然没有运气.这是我的佣金路线:
admin_dashboard /admin(.:format) {:action=>"index", :controller=>"admin/dashboard"}
admin_comments GET /admin/comments(.:format) {:action=>"index", :controller=>"admin/comments"}
admin_comments POST /admin/comments(.:format) {:action=>"create", :controller=>"admin/comments"}
new_admin_comment GET /admin/comments/new(.:format) {:action=>"new", :controller=>"admin/comments"}
edit_admin_comment GET /admin/comments/:id/edit(.:format) {:action=>"edit", :controller=>"admin/comments"}
admin_comment GET /admin/comments/:id(.:format) {:action=>"show", :controller=>"admin/comments"}
admin_comment PUT /admin/comments/:id(.:format) {:action=>"update", :controller=>"admin/comments"}
admin_comment DELETE /admin/comments/:id(.:format) {:action=>"destroy", :controller=>"admin/comments"}
new_admin_user_session GET /admin/login(.:format) {:action=>"new", :controller=>"active_admin/devise/sessions"}
admin_user_session POST /admin/login(.:format) {:action=>"create", :controller=>"active_admin/devise/sessions"}
destroy_admin_user_session DELETE /admin/logout(.:format) {:action=>"destroy", :controller=>"active_admin/devise/sessions"}
admin_user_password POST /admin/password(.:format) {:action=>"create", :controller=>"active_admin/devise/passwords"}
new_admin_user_password GET …Run Code Online (Sandbox Code Playgroud) 我们昨天对我们的后端做了很大的升级,现在我们遇到了一些奇怪的错误,我不知道它们是什么.尝试通过Twilio的客户端发送消息时,似乎发生了错误.此外,由于这些错误,我们相信我们的sidekiq队列中的东西正在备份.我们的sidekiq忙标签有一些等待的东西.以下是我们看到的一些错误:
这些在过去并没有发生在我们身上,现在它们经常发生.这是IOError的堆栈跟踪:关闭流错误:
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:155 in "select"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:155 in "rescue in rbuf_fill"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:152 in "rbuf_fill"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:134 in "readuntil"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:144 in "readline"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http/response.rb:39 in "read_status_line"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http/response.rb:28 in "read_new"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1408 in "block in transport_request"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1405 in "catch"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1405 in "transport_request"
/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1378 in "request"
/vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/net.rb:27 in "block (2 levels) in request_with_newrelic_trace"
/vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent.rb:454 in "disable_all_tracing"
/vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/net.rb:26 in "block in request_with_newrelic_trace"
/vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/cross_app_tracing.rb:38 in "tl_trace_http_request"
/vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/net.rb:23 in …Run Code Online (Sandbox Code Playgroud) 我有一个这样的工人:
class MassDispatchServiceWorker
include Sidekiq::Worker
sidekiq_options queue: :bulk
def perform(message_params)
DispatchService.new(message_params).dispatch!
end
end
Run Code Online (Sandbox Code Playgroud)
但是,我需要相同的方法,但将队列作为变量传递。有时我希望队列很大,有时我需要其他东西。sidekiq 可以吗?
我们向 8000 万行数据库添加了一个 UUID 列,并使用 postgres 函数生成默认值uuid_generate_v4()。
我们使用以下脚本回填 uuid:
current = 1
batch_size = 1000
last_id = 80000000
while current < last_id
start_id = current
end_id = current + batch_size
puts "WORKING ON current: #{current}"
ActiveRecord::Base.connection.execute <<-SQL.squish
UPDATE table_name
SET public_id = uuid_generate_v4()
WHERE id BETWEEN '#{start_id}' and '#{end_id}' AND public_id IS NULL
SQL
current = end_id + 1
end
Run Code Online (Sandbox Code Playgroud)
然而,在脚本的最后,我们发现有 135 个重复项,有些甚至有 3 个。这怎么可能呢?该uuid_generate_v4()函数产生重复的概率是否如此之高?
我找到了一个很好的正则表达式代码来检查素数.我想我明白了,但我仍然有点困惑.这是代码:/^1?$|^(11+?)\1+$/
有人可以解释(一步一步)正确的正则代码以及它与知道一个数字是否为素数的实际关系?
当我尝试做rails server和thin start,两人都说:"在任何一个源找不到的ActiveSupport-3.0.6."
我安装了activesupport-3.0.7.我是否需要还原以使activesupport与我的Rails版本(3.0.6)匹配?
如何修复数据库锁...因为我的测试没有通过 - 它在同一类别中进行了一系列测试失败.谢谢!
1) UsersController GET 'edit' should have a link to change the Gravatar
Failure/Error: @user = Factory(:user)
SQLite3::BusyException: database is locked: INSERT INTO "users" ("created_at", "email", "encrypted_password", "name", "salt", "updated_at") VALUES ('2011-05-29 03:47:07.510067', 'mberman84@gmail.com', 'fc70fcb4b094b388d87c5054ed9b0bfa06f53431d44c527e852c5bdffd3a0fa8', 'Matthew Berman', NULL, '2011-05-29 03:47:07.510067')
# ./spec/controllers/users_controller_spec.rb:128:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud) 我之前只创建了一个has_and_belongs_to_many关联,它与has_many:through不同.对于has_many:通过关联,我需要一个连接表吗?实际协会如何运作?我需要索引吗?我找不到一个很棒的教程,有什么建议吗?
我有一个项目列表,我想让列表中的第一个项目不可排序和不可移动。列表中的第一项应始终作为列表中的第一项。但是,我似乎无法让它工作。这是我的排序代码:
jQuery ->
$('#lineup').sortable(
axis: 'y'
items: ".ui-state-enabled"
cancel: ".ui-state-disabled"
update: ->
$.post($(this).data('update-url'), $(this).sortable('serialize'))
);
Run Code Online (Sandbox Code Playgroud)
我正在使用 content_tag_for 加载它:
%ul.nav.nav-tabs.nav-stacked#lineup{"data-update-url" => sort_lineups_url}
- @pieces.each_with_index do |piece, index|
- if index == 0
= content_tag_for(:li, piece, :class => 'ui-state-disabled') do
= link_to "#{(index + 1).to_s + ' - ' + piece.name}", '#'
- else
= content_tag_for(:li, piece, :class => 'ui-state-enabled') do
= link_to "#{(index + 1).to_s + ' - ' + piece.name}", '#'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我所做的一切似乎都无法阻止对第一项进行排序和/或移动
这是我的模特:
Interaction.rb
class Interaction < ActiveRecord::Base
belongs_to :report
belongs_to :post
belongs_to :fb_user
has_one :fb_page
Run Code Online (Sandbox Code Playgroud)
Report.rb
class Report < ActiveRecord::Base
belongs_to :user
has_many :page_stats,
dependent: :destroy
has_many :interactions,
dependent: :destroy
has_many :fb_users,
through: :interactions
has_one :fb_page,
foreign_key: :fb_id,
primary_key: :fb_page_id
has_many :posts,
dependent: :destroy
Run Code Online (Sandbox Code Playgroud)
FbUser.rb
class FbUser < ActiveRecord::Base
self.primary_key = "id"
has_many :interactions
Run Code Online (Sandbox Code Playgroud)
我想要做的是按照他们发生的一天中的小时进行交互.我正在寻找1-24(一天中的小时,UTC)的哈希值,并将交互计数按发生时间分组.
这是一个示例返回值:
{{1 => 23},{2 => 7},{n => x}}
基本上,对于第1小时,有23次互动,对于第2小时,有7次.我想每天1到24小时这样做.
交互有一个名为"interaction_time"的列,即交互发生时.谢谢
activerecord ×2
sidekiq ×2
activeadmin ×1
associations ×1
bundler ×1
has-many ×1
jquery ×1
jquery-ui ×1
postgresql ×1
regex ×1
twilio ×1
uuid ×1