我正在努力将Rails 2.3.11,Ruby 1.9.2应用程序升级到Rails 3.0.10,并且attachment_fu不再有效.
我正在寻找更改为paperclip,carrierwave或dragonfly的文件上传,或者可能是raails 3兼容,维护版本的attachment_fu.
哪些选项在性能方面最好用,维护得多好,从attachment_fu升级是多么容易,也许它会与Rails 3.1兼容?每个人的主要优点和缺点是什么?
任何见解将不胜感激.
attachment-fu paperclip ruby-on-rails-3 carrierwave dragonfly-gem
我正在努力从attachment_fu升级到carrierwave,因为attachment_fu在rails 3中被破坏了.
没有一个测试能够运行,因为我们有无效的灯具使用attachment_fu的语法来附件文件.
例如,我们有一个Post模型,它有一个PostAttachment.以下是PostAttachment夹具中的数据:
a_image:
post_id: 1
attachment_file: <%= Rails.root>/test/files/test.png
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
ActiveRecord::StatementInvalid: PGError: ERROR: column "attachment_file" of relation "post_attachments" does not exist
LINE 1: INSERT INTO "post_attachments" ("post_id", "attachment_file"...
Run Code Online (Sandbox Code Playgroud)
attachment_file 本来会被attachment_fu选中,它会处理为模型创建attachment_fu附件的所有处理.
有没有办法在灯具中有图像附件,但使用CarrierWave代替?
unit-testing ruby-on-rails fixtures ruby-on-rails-3 carrierwave
我正在升级从Rails的2.3.11到3.0.10,和我有麻烦将是什么在ApplicationController的filter_parameter_logging.我想过滤某些参数,如果它们出现在像:referrer标签这样的值中,也会对它们进行过滤.
我可以在我的网站中过滤掉常规参数 application.rb
config.filter_parameters += [:password, :oauth, ...]
Run Code Online (Sandbox Code Playgroud)
但我遇到的问题是我们也在filter_parameter_logging中传递的块.它还会过滤掉任何看起来像网址的值中的参数,因此http://example.com?password=foobar&oauth=123foo&page=2会将其记录为http://example.com?password=[FILTERED]&oauth=[FILTERED]&page=2.我需要一种方法让rails既可以过滤指定的参数,也可以过滤掉其他值中的参数,就像上面的url一样.
这是filter_parameter_logging中的样子:
FILTER_WORDS = %{password oauth email ...}
FILTER_WORDS_REGEX = /#{FILTER_WORDS.join("|")}/i
#Captures param in $1 (would also match things like old_password, new_password), and value in $2
FILTER_WORDS_GSUB_REGEX = /((?:#{FILTER_WORDS.join("|")})[^\/?]*?)(?:=|%3D).*?(&|%26|$)/i
filter_parameter_logging(*FILTER_WORDS) do |k,v|
begin
# Bail immediately if we can
next unless v =~ FILTER_WORDS_REGEX && (v.index("=") || v.index("%3D"))
#Filters out values for params that match
v.gsub!(FILTER_WORDS_GSUB_REGEX) do
"#{$1}=[FILTERED]#{$2}"
end
rescue Exception => …Run Code Online (Sandbox Code Playgroud) 我将旧的Ruby(1.8.7)和Rails(2.2.2)应用程序迁移到Ruby(1.9.3)和Rails(3.2.12)之后,遵循所有这些优秀的参考资料:
Rails升级脚本
Rails 3迁移博客
启动Rails 3应用程序
我可以启动应用程序的Rails服务器,但是当我通过浏览器访问应用程序,然后是BLAMMO!我收到服务器错误:
!处理请求时出现意外错误:未定义方法`session ='for ActionController :: Base:Class
当我grep -r为"session ="时,我得到:
/var/www/vendor_sandbox/config/application.rb: config.action_controller.session = {
/var/www/vendor_sandbox/config/environment.rb.rails2: config.action_controller.session = {
/var/www/vendor_sandbox/destroy/config/environment.rb: config.action_controller.session = {
/var/www/vendor_sandbox/generate/config/environment.rb: config.action_controller.session = {
Run Code Online (Sandbox Code Playgroud)
根据Google搜索该错误,这是Rails 2的一个老问题,所以我想知道如果我在迁移过程中遗漏了某些内容,或者这是否是其他内容.谢谢
这是我的终端会话活动:
root@partners:/var/www/vendor_sandbox# ruby -v
ruby 1.9.3p385 (2013-02-06 revision 39114) [i686-linux]
root@partners:/var/www/vendor_sandbox# rails --version
Rails 3.2.12
root@partners:/var/www/vendor_sandbox# rails s
=> Booting Thin
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.0 codename …Run Code Online (Sandbox Code Playgroud)