Tag: ruby on rails plugins

使用Ruby 1.8.7的未定义方法`has_attached_file’,带有paperclip 2.3.8 gem for Rails 2

我正在尝试使用我的rails应用程序中的paperclip插件上传post的图像。 我在Ubuntu 10.04操作系统上使用Rails 2.0.2和ruby 1.8.7用于项目特定目的。 我指的是以下教程: – http://railscasts.com/episodes/134-paperclip?view=comments http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails.html 我通过以下方式在paperclip插件上做了一个git clone: – https://github.com/thoughtbot/paperclip ,但像ruby script/generate paperclip group_post photo这样的命令没有为它生成迁移。 然后,我通过ruby脚本/生成创建了相同的迁移,并上传了我的表group_posts的相应列。 然后我尝试安装gem,因为我使用activerecord和activesupport 2.0.2我使用了rubygems.org的paperclip 2.3.8 gem。未定义的方法错误仍然存​​在,我真的无法弄清楚为什么。 现在这里..命令ruby script/generate paperclip group_post photo对我来说非常好。 我得到的当前错误看起来像这样: – undefined method `has_attached_file’ for # 我观察到这个行为的一个有趣的事情就是当我使用IRB时, require ‘paperclip’返回true但我想知道为什么他们无法检测我的rails应用程序中插件附带的方法。 该应用程序跟踪是: – /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activerecord-2.0.2/lib/active_record/base.rb:1532:in `method_missing_without_paginate’ vendor/plugins/will_paginate/lib/will_paginate/finder.rb:170:in `method_missing’ app/models/group_post.rb:9 app/controllers/groups_controller.rb:27:in `show’ 以下是完整跟踪 : – /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activerecord-2.0.2/lib/active_record/base.rb:1532:in `method_missing_without_paginate’ vendor/plugins/will_paginate/lib/will_paginate/finder.rb:170:in `method_missing’ app/models/group_post.rb:9 […]

运行思考Sphinx与Rails 2.3.5的问题

我刚安装了Sphinx(发行版:archlinux)下载源代码。 然后我为Rails安装了“Thinking Sphinx”插件。 我按照官方页面设置和Ryan Bates的这个Screencast ,但是当我尝试索引模型时,它给了我这个错误: $ rake thinking_sphinx:index (in /home/benoror/Dropbox/Proyectos/cotizahoy) Sphinx cannot be found on your system. You may need to configure the following settings in your config/sphinx.yml file: * bin_path * searchd_binary_name * indexer_binary_name For more information, read the documentation: http://freelancing-god.github.com/ts/en/advanced_config.html Generating Configuration to /home/benoror/Dropbox/Proyectos/cotizahoy/config/development.sphinx.conf sh: indexer: command not found 我尝试手动启动守护进程(/ usr / […]

多级块方法正在产生问题

我上课了 class DataListBuilder include ActionView::Helpers::TagHelper include ActionView::Helpers::CaptureHelper include ActionView::Helpers::UrlHelper attr_accessor :object, :output_buffer def initialize(object) @object, @output_buffer = object, nil end def column (&block) if block_given? content_tag(:li, block.call(self)) else content_tag(:li, “”) end end def options_column(&link_block) if block_given? content_tag(:li, content_tag(:dl, ” #{link_block.call(self)}”.html_safe, :class=>’options’)) else content_tag(:li, “”) end end def link_item(title, url, options={}) content_tag :li, link_to(title, url, options) end […]

什么是Rails插件或Ruby gem来自动修复英语语法?

Facebook刚刚重新启动了评论,具有自动语法修复function。 语法filter有什么作用? 添加标点符号(例如句子末尾的句点) 修剪额外的空白自动案例单词(例如,将句子的第一个单词大写) 扩展俚语(例如,PLZ变为请) 在标点符号后添加空格(例如Hi,Cat会变成Hi,Cat) 修复常见的语法错误(例如将’不要’转换为’不要’) 什么是等效的插件或gem?

启动或确保在应用程序/服务器重新启动时运行延迟作业

我们必须使用delayed_job(或其他一些后台作业处理器)在后台运行作业,但我们不允许更改服务器上的启动脚本/启动级别。 这意味着如果提供程序重新启动服务器,则不保证守护程序仍然可用(因为守护程序将由每个部署仅运行一次的capistrano配方启动)。 目前,我能想到确保delayed_job守护程序始终运行的最佳方法是向我们的Rails应用程序添加一个初始化程序,以检查守护程序是否正在运行。 如果它没有运行,那么初始化程序启动守护进程,否则它就会离开它。 因此,问题是我们如何检测到Delayed_Job守护程序是从脚本内部运行的? (我们应该能够相当容易地启动一个守护进程,我不知道如何检测一个守护进程是否已经激活)。 有人有主意吗? 此致,伯尼 基于下面的答案,这就是我提出的。 只需将它放在config / initializers中就可以了: #config/initializers/delayed_job.rb DELAYED_JOB_PID_PATH = “#{Rails.root}/tmp/pids/delayed_job.pid” def start_delayed_job Thread.new do `ruby script/delayed_job start` end end def process_is_dead? begin pid = File.read(DELAYED_JOB_PID_PATH).strip Process.kill(0, pid.to_i) false rescue true end end if !File.exist?(DELAYED_JOB_PID_PATH) && process_is_dead? start_delayed_job end

最好的Rails标记插件/gem

你推荐用于标记的插件或gem是什么? 其中有很多,acts_as_taggable,acts_as_taggable_on_steroids,acts_as_taggable_on,… 你说什么?