你们中的任何人都设法让Carrierwave的Active Admin工作吗?
当我安装AA时,一切正常,但图像文件上传字段是纯文本字段,因此添加如下:
ActiveAdmin.register Club do
form do |f|
f.inputs "Club" do
f.input :league
f.input :name
f.input :image, :as => :file
f.input :approved
end
f.buttons
end
end
Run Code Online (Sandbox Code Playgroud)
现在它显示为文件上传字段,我可以选择一个文件,但在我提交表单后没有任何改变.仍然没有图像,图像字段为空.任何人都知道还有什么可以让它工作?
有没有办法只使用
http_basic_authenticate_with :name => 'user', :password => 'secret'
Run Code Online (Sandbox Code Playgroud)
当服务器在生产模式下运行时?
有什么办法可以将HTML转换为正确的纯文本吗?我尝试了从raw到sanitize的所有东西,甚至还有使用text_part方法的Mail gem,它本应该做到这一点,但对我来说不起作用.
到目前为止,我最好的射门是,strip_tags(strip_links(resource.body))但等等没有正确转换.<p><ul>
这或多或少是我在HTML中的含义:
Hello
This is some text. Blah blah blah.
Address:
John Doe
10 ABC Street
Whatever City
New Features
- Feature A
- Feature B
- Feature C
Check this out: http://www.google.com
Best,
Admin
Run Code Online (Sandbox Code Playgroud)
转换成类似的东西
Hello
This is some text. Blah blah blah.
Address: John Doe 10 ABC Street Whatever City
New Features Feature A Feature B Feature C
Check this out: http://www.google.com
Best, Admin
Run Code Online (Sandbox Code Playgroud)
任何的想法?
我在很长一段时间运行后,Debian服务器和升级的所有软件包(apt-get update,apt-get upgrade,apt-get distro-upgrade).然后rmagick不再工作了因为imagemagick被更新了.
所以我跑了:
gem uninstall rmagick
bundle install
Run Code Online (Sandbox Code Playgroud)
然后我得到了这个:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 0.0.0. Can't find Magick-config in /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need …Run Code Online (Sandbox Code Playgroud) 几天前我让brew更新我所有的配方师,但这次mysqld没有重新开始.
这是错误消息:
2016-03-22T13:58:22.515719Z 0 [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
2016-03-22T13:58:22.515819Z 0 [ERROR] Aborting
Run Code Online (Sandbox Code Playgroud)
但由于我无法启动服务器,我无法运行mysql_upgrade:
mysql_upgrade: Got error: 2013: Lost connection to MySQL server at 'reading initial communication packet', system error: 102 while connecting to the MySQL server
Upgrade process encountered error and will not continue.
Run Code Online (Sandbox Code Playgroud)
那么我该怎样做才能让它重新开始呢?会brew uninstall mysql以任何方式重新安装帮助吗?
我在Rails 3.1.3中创建了一个新引擎,显然有一个rake任务可以复制所有迁移.我试过以下rake abc:install:migrations扔了:
rake aborted!
Don't know how to build task 'abc:install:migrations'
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
我也试过rake abc_engine:install:migrations了同样的结果.
然后我读bundle exec rake railties:install:migrations或bundle exec rake railties:install:migrations FROM=abc_engine应该做的伎俩,但没有成功.即使没有抛出任何错误,也没有复制任何内容.
我的迁移位于引擎文件夹中的db/migrate /中,我从spec/dummy /运行上面的所有命令
有谁知道如何使用这个新的rake任务来从引擎复制迁移?
rake ruby-on-rails rails-migrations rails-engines ruby-on-rails-3.1
我今天尝试使用RVM安装Ruby 2,但它失败了.我更新了RVM,我所有的酿造配方和诸如此类的东西.这就是我得到的:
admin:/$ rvm install ruby-2.0.0-p0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Already up-to-date.
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Installing Ruby from source to: /Users/admin/.rvm/rubies/ruby-2.0.0-p0, this may take a while depending on your cpu(s)...
ruby-2.0.0-p0 - #downloading ruby-2.0.0-p0, this may take a while depending on your …Run Code Online (Sandbox Code Playgroud) 我正在努力完成一个相当容易的任务,它有一个非负整数数组,我需要返回最近的距离.
阵: arr = [8, 24, 3, 20, 1, 17]
解决方案:2,arr[2]-arr[4]
到目前为止,我只设法写了一个O(n ^ 2)解决方案,这显然不够好:
def smallest_distance(a)
result = nil
a.each_with_index do |item1, index1|
a.each_with_index do |item2, index2|
next if index1 == index2
temp = (item1 - item2) >= 0 ? item1 - item2 : item2 - item1
result = temp if result.nil? || temp < result
end
end
result
end
Run Code Online (Sandbox Code Playgroud)
关于如何改进这个的任何想法?
我正在尝试访问我的RSpec测试中的夹具数据,但似乎没有加载任何.
spec_helper.rb
config.fixture_path = "#{::Rails.root}/db/fixtures"
config.use_transactional_fixtures = true
config.global_fixtures = :all
Run Code Online (Sandbox Code Playgroud)
这是我的一个装置:
cash:
name: cash
interest: 1
term: <%= Time.now.to_s :db %>
Run Code Online (Sandbox Code Playgroud)
现在测试正在创建一个具有after_create回调的用户:
ft = FundType.find_by_name("cash")
Fund.create(fund_type_id: ft.id, amount: 1000) <--- this is where the error occurs
Run Code Online (Sandbox Code Playgroud)
错误:
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我试图用rspec获得回溯,但由于某种原因我不能让它工作.
这是测试文件:
require 'spec_helper'
describe ActivityReport do
it "should create a new instance given valid attributes" do
activity = Factory(:activity_report)
end
Run Code Online (Sandbox Code Playgroud)
这是我运行的命令:
rspec --backtrace spec/models/activity_report_spec.rb
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:
No examples matched {:focus=>true}. Running all.
ActivityReport
should create a new instance given valid attributes (FAILED - 1)
Failures:
1) ActivityReport should create a new instance given valid attributes
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /Users/pbartels/.rvm/gems/ruby-1.9.2-p290@brothelking/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:206
Finished in 40.76 seconds
1 example, 1 failure
Failed examples: …Run Code Online (Sandbox Code Playgroud) 我正在从许多不同的来源导出CSV,这使得在将其放入CSV之前很难进行排序。
csv = CSV.generate col_sep: '#' do |csv|
... adding a few columns here
end
Run Code Online (Sandbox Code Playgroud)
现在,如果我能够按第二列对CSV进行排序,那就太好了。有可能吗?
rspec ×2
rspec2 ×2
activeadmin ×1
algorithm ×1
backtrace ×1
carrierwave ×1
csv ×1
file-upload ×1
fixtures ×1
homebrew ×1
html-to-text ×1
imagemagick ×1
mysql ×1
rake ×1
rmagick ×1
ruby-2.0 ×1
rvm ×1
sorting ×1