未定义的方法`has_attached_file'与回形针2.3.8 gem for Rails 2使用Ruby 1.8.7 [英] Undefined method `has_attached_file' with paperclip 2.3.8 gem for Rails 2 using Ruby 1.8.7

查看:186
本文介绍了未定义的方法`has_attached_file'与回形针2.3.8 gem for Rails 2使用Ruby 1.8.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的rails应用程序中使用回形针插件来上传图片。我在Ubuntu 10.04 os上使用了Rails 2.0.2和ruby 1.8.7,用于项目特定目的。

我指的是以下教程: -


  1. http://jimneath.org/2008/04/17/paperclip-attaching-files-in -ails.html


我在回形针插件上做了一个git clone: - https://github.com/thoughtbot/paperclip ,但是像 ruby​​ script /生成回形针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 对我来说工作得很好。



目前的错误我正好看起来像这样: - $ / b>

 未定义的方法`has_attached_file'为#< Class:0xb67119f0> 

我观察到这种行为的一个有趣的事情是当我使用IRB时, require'paperclip'返回 true 但是我想知道他们为什么无法检测到我的rails应用程序中插件的方法。

Application Trace 同样是: -

  /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在/ show / app / controllers /

Full Trace 这个例子是: -

  /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:在`method_missing'
app / models / group_post.rb:9
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/ lib / active_support / dependencies.rb:203:`load_without_new_constant_marking'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies。 rb:203:在`load_file'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in` new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in`load_file'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in`require_or_load'
/ home / mohnish /。 rvm / gems / ruby​​-1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:248:在`load_missing_constant'
/home/mohnish/.rvm/gems/ruby- 1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:453:在`const_missing_not_from_s 3_library'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in' const_missing'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in`const_missing'
/ home /mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:471:in`send'
/home/mohnish/.rvm/ gems / ruby​​-1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:471:在`const_missing'
app / controllers / groups_controller.rb:27:在`show'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in`send'
/ home /mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in`perform_action_without_filters'
/home/mohnish/.rvm/ gem / ruby​​-1.8.7-p334 / gems / actionpack-2.0.2 / lib / action_controller / filters.rb:697:在`call_filters'
/home/mohnish/.rvm/gems/ruby-1.8。 7-P334 /宝石/ actionpa ck-2.0.2 / lib / action_controller / filters.rb:689:在`perform_action_without_benchmark'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/ lib / action_controller / benchmarking.rb:68:在`perform_action_without_rescue'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/benchmark.rb:293:in`测量'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in`perform_action_without_rescue'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in`perform_action_without_caching'
/ home / mohnish /。 rvm / gems / ruby​​-1.8.7-p334 / gems / actionpack-2.0.2 / lib / action_controller / caching.rb:678:在`perform_action'
/home/mohnish/.rvm/gems/ruby- 1.8.7-p334 / gems / activerecord-2.0.2 / lib / active_record / connection_adapters / abstract / query_cache.rb:33:在`cache'
/home/mohnish/.rvm/gems/ruby-1.8。 7-p334 / gems / activerecord-2.0.2 / lib / active_record / query_cache.rb:8:在`cache'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in`perform_action'
/ home / mohnish / .rvm / gems / ruby​​-1.8.7-p334 / gems / actionpack-2.0.2 / lib / action_controller / base.rb:524:在'send'
/home/mohnish/.rvm/gems /ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in`process_without_filters'
/home/mohnish/.rvm/gems/ruby-1.8.7 -p334 / gems / actionpack-2.0.2 / lib / action_controller / filters.rb:685:in`process_without_session_management_support'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack -2.0.2 / lib / action_controller / session_management.rb:123:在`process_without_test'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib /action_controller/test_process.rb:15:in'process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb :388:在`process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispa tcher.rb:171:`handle_request'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115: in`dispatch'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in`dispatch_cgi'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in`dispatch'
/ home / mohnish /.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in`process'
/home/mohnish/.rvm/gems/ ruby-1.8.7-p334 / gems / mongrel-1.1.5 / lib / mongrel / rails.rb:74:在`synchronize'
/home/mohnish/.rvm/gems/ruby-1.8.7- p334 / gems / mongrel-1.1.5 / lib / mongrel / rails.rb:74:在`process'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel- 1.1.5 / lib / mongrel.rb:159:在`process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel。 rb:158:在'each'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:15 8:在`process_client'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in`run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in`initialize'
/ home / mohnish /。 rvm / gems / ruby​​-1.8.7-p334 / gems / mongrel-1.1.5 / lib / mongrel.rb:285:在`new'
/home/mohnish/.rvm/gems/ruby-1.8。 7-p334 / gems / mongrel-1.1.5 / lib / mongrel.rb:285:在`run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel- 1.1.5 / lib / mongrel.rb:268:在`initialize'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel。 rb:268:在`new'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in`run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in`run'
/ home /mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in`each'
/home/mohnish/.rvm/宝石/红宝石1.8.7-P334 /宝石/杂种-1.1.5 / LIB /杂种/配置器。 rb:281:在`run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:128:in`run'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in`run'
/ home / mohnish /.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems /activesupport-2.0.2/lib/active_support/dependencies.rb:489:in`load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2 /lib/active_support/dependencies.rb:489:in`load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies .rb:342:在`new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
/ home /mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in` gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`require'
/ home /mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require'
/home/mohnish/.rvm/ gems / ruby​​-1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:342:在`new_constants_in'
/home/mohnish/.rvm/gems/ruby-1.8。 7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:496:在'require'中
/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/ rails-2.0.2 / lib / commands / server.rb:39
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb :31:`gem_original_require'
/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`require'
脚本/服务器:3

我的groups_controller.rb show方法看起来像这样,这里是第27行是 @group_post =组Post.new(params [:group_post]): -

  def show 
@ investor_group = InvestorGroup.find(params [:id])
@members = @ investor_group.activated_members
#来自讨论方法的代码
investor_id = session ['investor_id']
@投资者= Investor.find(investor_id)

@members = @ investor_group.activated_members

除非@ current_user.is_an_existing_member_of_group(@investor_group)
flash [:notice] = 请加入这个小组参与讨论
redirect_to:action => :show,:id => @investor_group并返回
else
@group_post = GroupPost.new(params [:group_post])#第27行,试过GroupPost.create也..似乎是没有用的..
结束
#@ group_post = GroupPost.new(params [:group_post])
@ group_post.investor_group_id = @ investor_group.id
@ group_post.post_by = investor_id
除非@ group_post.message 。空白?
如果@ group_post.save
flash [:notice] ='发表成功了'
else
flash [:notice] ='发表不成功
结束
#redirect_to:action => :show,:id => @investor_group并返回更改..适当....
结束
#if @ group_post.message.blank?
#flash [:notice] ='帖子不能为空'
#end
@group_all_posts = GroupPost.find(:all,:conditions => ['investor_group_id )='','#{@investor_group.id}],:order =>'created_at DESC')
#来自讨论方法的代码
结束

group_post模型看起来像这样,第9行有以下代码has_attached_file:photo: - $ /

class GroupPost < ActiveRecord :: Base
has_many:group_comments
belongs_to:investor_group
validates_presence_of:message



#include Paperclip
requirepaperclip
#Paperclip
has_attached_file:photo#line 9



end

我的视图文件,我试图上传图片以及一个职位看起来像这样: - $ / b>

 <%form_for:group_post ,@group_post,:url => {:action => :show},:html => {:multipart => 'true'},:id => 'new_post'do | f | - %GT; 
< p>< label>开始讨论:< / label>< br><%= f.text_field:message%>< / p>
<%= f.file_field:photo%>< / p>
< p><%= submit_tag发布%>< / p>
<%end%>

我尝试了以下内容: - $ /


  • 为什么在安装PaperClip时为`has_attached_file`定义了一个未定义的方法?



  • 因为它似乎使用的是
    以上的Rails版本。



    • Paperclip安装后的未定义方法has_attached_file?



      我尝试重新启动我的服务器,但没有解决我的问题;

    • com / thoughtbot / paperclip / issues / 192rel =nofollow noreferrer> https://github.com/thoughtbot/paperclip/issues/192


      ul>

      我尝试了包括Paperclip - 但它r eally似乎没有帮助我的情况...

      我已经在我的group_post.rb和我的environment.rb文件中添加了一个require作为requirepaperclip。我仍然得到一个未定义的方法错误。我不知道为什么..





      Imumar的回形针叉,我手动粘贴在我的供应商/插件目录git克隆后..我得到了以下错误(我有一种感觉肯定会有一个依赖性的问题,因为他的版本可能只与一个更高的轨道兼容版本:

      pre $ mo $ c $ mohnish桌面〜/ UP / dev $ ruby​​脚本/服务器-p 4000
      = >引导Mongrel(使用脚本/服务器webrick来强制WEBrick)
      =>从http://0.0.0.0:4000开始的Rails应用程序
      =>使用-d分开
      => Ctrl-C关闭服务器
      **以0.0.0.0:4000开始Mongrel侦听
      **使用开发环境启动Rails ...
      退出
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gem s / activesupport-2.0.2 / lib / active_support / dependencies.rb:263:in`load_missing_constant':未初始化的常量Paperclip :: CallbackCompatability :: Rails20(NameError)$ b $ from /home/mohnish/.rvm/gems/ ruby-1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:453:在`const_missing'
      从/ home / mohnish / UP / dev / vendor / plugins / paperclip / lib / paperclip.rb:118:在`included'
      from /home/mohnish/UP/dev/vendor/plugins/paperclip/lib/paperclip.rb:364:in`include'
      from / home / mohnish / UP / dev / vendor / plugins / paperclip / lib / paperclip.rb:364:从/ home / mohnish / UP / dev / vendor / plugins / paperclip / lib / paperclip发送
      。 rb:364
      from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem_original_require'
      from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`require'
      from / home / mohnish /。 RVM /宝石/红宝石1.8.7-P334 /宝石/活性support-2.0.2 / lib / active_support / dependencies.rb:496:在'require'中
      来自/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2 /lib/active_support/dependencies.rb:342:in`new_constants_in'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/依赖关系.rb:496:在`require'
      from /home/mohnish/UP/dev/vendor/plugins/paperclip/init.rb:1:in`evaluate_init_rb'$ b $ from / home / mohnish / .rvm / gems / ruby​​-1.8.7-p334 / gems / rails-2.0.2 / lib / rails / plugin.rb:79:在`evaluate_init_rb'
      from /home/mohnish/.rvm/gems/ ruby-1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / core_ext / kernel / reporting.rb:11:在'silence_warnings'
      from /home/mohnish/.rvm/gems/ruby -1.8.7-p334 / gems / rails-2.0.2 / lib / rails / plugin.rb:75:在`evaluate_init_rb'
      from /home/mohnish/.rvm/gems/ruby-1.8.7- p334 / gems / rails-2.0.2 / lib / rails / plugin.rb:39:`load'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails -2。 0.2 / lib / rails / plugin / loader.rb:33:`load_plugins'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib /rails/plugin/loader.rb:32:in`each'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/ plugin / loader.rb:32:`load_plugins'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:189 :在`load_plugins'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:105:in`process'$ b $ from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:49:in`send'
      from / home / mohnish /.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:49:in`run'$ b $ from / home / mohnish / UP / dev / config / environment.rb:16
      from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem_original_require'$ b来自/home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/ruby的$ b gems / custom_require.rb:31:`require'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb :496:在`require'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in` 'new_constants_in'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in`rails'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:113:in`cloaker_'
      from /home/mohnish/.rvm /gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:149:in`call'
      from /home/mohnish/.rvm/gems/ruby- 1.8.7-p334 / gems / mongrel-1.1.5 / lib / mongrel / configurator.rb:149:在`listener'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334 /gems/mongrel-1.1.5/bin/mongrel _rails:99:`cloaker_'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:50:in从/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:50:in`initialize'$ b调用
      $ / from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:84:in`new'
      from / home / mohnish /。 rvm / gems / ruby​​-1.8.7-p334 / gems / mongrel-1.1.5 / bin / mongrel_rails:84:在`run'
      从/home/mohnish/.rvm/gems/ruby-1.8.7 -p334 / gems / mongrel-1.1.5 / lib / mongrel / command.rb:212:在`run'
      从/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/ mongrel-1.1.5 / bin / mongrel_rails:281
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb: 489:在`load'中
      从/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:在`load '来自/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/a的
      ctivesupport-2.0.2 / lib / active_support / dependencies.rb:342:在`new_constants_in'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2 /lib/active_support/dependencies.rb:489:in`load'
      from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/ servers / mongrel.rb:64
      from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem_original_require' / home / mohnish /.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire
      from / home /mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in`require'
      from /home/mohnish/.rvm /gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in`new_constants_in'
      from /home/mohnish/.rvm/gems/ruby- 1.8.7-p334 / gems / activesupport-2.0.2 / lib / active_support / dependencies.rb:496:在`require'
      中/home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
      from /home/mohnish/.rvm/rubies/ ruby-1.8.7-p334 / lib / ruby​​ / site_ruby / 1.8 / ruby​​gems / custom_require.rb:31:在`gem_original_require'
      from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334 /lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`require'
      from script / server:3
      mohnish @ mohnish-desktop:〜/ UP / dev $

      我真的很想知道我要去哪里。

      任何建议/见解将不胜感激。这对我来说是迫切的,因为我有一个部署到期,我会很高兴得到及时的答复/答复。

      非常感谢..

      $首先,为了覆盖显而易见的基础:做供应商/插件只是为了确保某个版本的回形针是实际上在你的插件目录中,因此你的应用程序是可以访问的。

      其次,模型中的require paperclip似乎是错误的。我猜测,要求应该在你的环境中进行。试试把它放在config / environments.rb的末尾。



      第三(也许和你的具体问题无关) - 2.0.2是一个非常老的rails版本。如果你可以,我会升级到2.3.5,或者至少是2.2.x.对于我们所知道的 - 你可能会遇到一个问题,因为你有一个新的回形针和一个老版本的轨道...这有时会有所作为。



      你发布的其他许多链接都是指Rails3之前的安装 - 因此,他们问题的解决方案将与你的不同。


      I am trying to use the paperclip plugin in my rails app to upload images for posts. I am using Rails 2.0.2 and ruby 1.8.7 on Ubuntu 10.04 os for project specific purposes.

      I am referring to the following tutorials for this :-

      1. http://railscasts.com/episodes/134-paperclip?view=comments

      2. http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails.html

      I did a git clone on the paperclip plugin via:- https://github.com/thoughtbot/paperclip , but the command like ruby script/generate paperclip group_post photo didn't generate a migration for it. I then created a migration for the same through ruby script/generate and uploaded the appropriate columns of my table group_posts.

      I then tried to install the gem and since I am using activerecord and activesupport 2.0.2 I used paperclip 2.3.8 gem from rubygems.org.The undefined method error still persisted, I really couldn't figure out why.

      Now here.. the command ruby script/generate paperclip group_post photo worked perfectly fine for me.

      The current error I am getting exactly looks like this:-

      undefined method `has_attached_file' for #<Class:0xb67119f0>
      

      A funny thing that I observed wrt this behavior was when I made use of IRB, require 'paperclip' returned true but I wonder why they can't detect the method that comes along with the plugin in my rails app.

      The Application Trace for the same is:-

      /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'
      

      The Full Trace for this just in case is:-

      /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
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_file'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing_not_from_s3_library'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:471:in `send'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:471:in `const_missing'
      app/controllers/groups_controller.rb:27:in `show'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in `send'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in `perform_action_without_filters'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
      /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/benchmark.rb:293:in `measure'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process_without_test'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/test_process.rb:15:in `process'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
      /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
      /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
      /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
      /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
      script/server:3
      

      My groups_controller.rb show method looks like this, here line 27 is @group_post = GroupPost.new(params[:group_post]) :-

        def show
          @investor_group = InvestorGroup.find(params[:id])
          @members = @investor_group.activated_members
          # code taken from discuss method
          investor_id = session['investor_id']
          @investor = Investor.find(investor_id)
      
          @members = @investor_group.activated_members
      
          unless @current_user.is_an_existing_member_of_group(@investor_group)
              flash[:notice] = "Please join this group to participate in discussions"
              redirect_to :action => :show, :id => @investor_group and return
          else
             @group_post = GroupPost.new(params[:group_post]) # line 27, tried GroupPost.create also.. seems to be of no avail..
          end
          #@group_post = GroupPost.new(params[:group_post])
            @group_post.investor_group_id = @investor_group.id
            @group_post.post_by = investor_id
          unless @group_post.message.blank?
            if @group_post.save
              flash[:notice] = 'Post was successfull'
           else
              flash[:notice] = 'Post was not successfull'
            end
             #redirect_to :action => :show, :id => @investor_group and return to change.. appropriately....
          end
          #if @group_post.message.blank?
          #  flash[:notice] = 'Post can\'t be blank.'
          #end
          @group_all_posts  = GroupPost.find(:all, :conditions => [ 'investor_group_id = ?', "#{@investor_group.id}" ], :order => 'created_at DESC')
          # code taken from discuss method
        end
      

      The group_post model looks like this with line 9 having the following code has_attached_file :photo :-

      class GroupPost < ActiveRecord::Base has_many :group_comments belongs_to :investor_group validates_presence_of :message

      #include Paperclip require "paperclip" # Paperclip has_attached_file :photo # line 9

      end

      Part of my view file where I am trying to upload the picture along with a post looks like this:-

      <%form_for  :group_post, @group_post, :url => {:action => :show},:html => {:multipart => 'true'},:id => 'new_post' do |f| -%>
          <p><label>Start Discussion:</label><br><%=f.text_field :message%></p>
         <%=f.file_field :photo%></p> 
         <p><%=submit_tag "Post"%></p>
        <%end%>
      

      I tried what was given in:-

      This option didn't seem applicable to my case as it seems to be using a higher Rails version

      I tried the include Paperclip - but it really didn't seem to help my case...

      I have added a require in my group_post.rb and in my environment.rb file as require "paperclip". I still get an undefined method error. I don't know why..

      On referring to this I tried Imumar's fork of paperclip, I manually pasted it in my vendor/plugins directory after git cloning it.. I got the following error( I have a feeling there surely would have been a dependency issue as his version might be compatible only with a higher rails version:

      mohnish@mohnish-desktop:~/UP/dev$ ruby script/server -p 4000
      => Booting Mongrel (use 'script/server webrick' to force WEBrick)
      => Rails application starting on http://0.0.0.0:4000
      => Call with -d to detach
      => Ctrl-C to shutdown server
      ** Starting Mongrel listening at 0.0.0.0:4000
      ** Starting Rails with development environment...
      Exiting
      /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant Paperclip::CallbackCompatability::Rails20 (NameError)
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
          from /home/mohnish/UP/dev/vendor/plugins/paperclip/lib/paperclip.rb:118:in `included'
          from /home/mohnish/UP/dev/vendor/plugins/paperclip/lib/paperclip.rb:364:in `include'
          from /home/mohnish/UP/dev/vendor/plugins/paperclip/lib/paperclip.rb:364:in `send'
          from /home/mohnish/UP/dev/vendor/plugins/paperclip/lib/paperclip.rb:364
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
          from /home/mohnish/UP/dev/vendor/plugins/paperclip/init.rb:1:in `evaluate_init_rb'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/plugin.rb:79:in `evaluate_init_rb'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/plugin.rb:75:in `evaluate_init_rb'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/plugin.rb:39:in `load'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/plugin/loader.rb:33:in `load_plugins'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/plugin/loader.rb:32:in `each'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/rails/plugin/loader.rb:32:in `load_plugins'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:189:in `load_plugins'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:105:in `process'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:49:in `send'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/initializer.rb:49:in `run'
          from /home/mohnish/UP/dev/config/environment.rb:16
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:149:in `call'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:149:in `listener'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:50:in `call'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:50:in `initialize'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/mongrel-1.1.5/bin/mongrel_rails:281
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
          from /home/mohnish/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.0.2/lib/commands/server.rb:39
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
          from /home/mohnish/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
          from script/server:3
      mohnish@mohnish-desktop:~/UP/dev$ 
      

      I really wonder where I am going wrong..

      Any suggestions/insights would be highly appreciated. This is urgent for me as I have a deployment due, I would be really glad to get prompt answers/responses..

      Thanks a lot..

      解决方案

      Ok, firstly, just to cover the "obvious" base: do "ls vendor/plugins" just to make sure that some version of paperclip is actually in your plugins directory and is therefore reachable by your application.

      Secondly - the "require paperclip" in the model seems wrong to me. I'm guessing that require should go in your environment instead. Try putting it at the end of config/environments.rb instead.

      Thirdly (and maybe unrelated to your specific problem) - 2.0.2 is a really old version of rails. If you can I'd upgrade to 2.3.5, or at the very least, 2.2.x. For all we know - you could have a problem because you've got a new version of paperclip and an old version of rails... this does sometimes make a difference.

      A lot of the other links you posted are referring to installations up to Rails3 - the solutions to their problems will be different to yours for that reason.

      这篇关于未定义的方法`has_attached_file'与回形针2.3.8 gem for Rails 2使用Ruby 1.8.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆