为什么我的Rails不上传文件?

时间:2013-02-13 20:53:57

标签: ruby-on-rails ruby redmine

Rails 3.2.12

Ruby 1.9.3

Redmine 2.2.3

Centos 6.3

我不是Rails专家,但我接到了升级Redmine的任务。 http://www.redmine.org/

Redmine很容易,但插件非常困难。其中,我被要求安装这个插件:

https://github.com/reubenmallaby/redmine_embedded

我以为我已经正确安装了这个。如果我以管理员身份登录Redmine,我可以看到该模块,它为我提供了以下表单:

  <form accept-charset="UTF-8" action="/projects/timeout/embedded/upload" enctype="multipart/form-data" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="LjMzA63/L+G8Uj/1/uFefLYMJ1MxOTdTB516XTS6rjE=" /></div>    <fieldset id="embedded_doc" class="collapsible collapsed">
      <legend onclick="toggleFieldset(this);">Upload documentation</legend>
      <div style="display: none;">
        Select File (ZIP format only, root must be html directory): 
        <input id="upload_datafile" name="upload[datafile]" type="file" />
        <input name="commit" type="submit" value="Upload" />
        </div>
    </fieldset>
</form>

在插件的配置中,我将上传文件夹设置为:

/home/cehovice/redmine-2.2/public/uploads/{PROJECT}/html

我在uploads文件夹上做了chmod 0777。

我尝试上传HTML文件,但没有上传任何内容。

如果我查看Phusion Passenger Standalone的终端输出,我看到:

Started POST "/projects/men_of_fashion/embedded/upload" for 10.0.1.53 at 2013-02-13 15:11:02 -0500
Processing by RedmineEmbeddedController#upload as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"LjMzA63/L+G8Uj/1/uFefLYMJ1MxOTdTB516XTS6rjE=", "upload"=>{"datafile"=>#<ActionDispatch::Http::UploadedFile:0x00000006f54708 @original_filename="tositeconfig.html", @content_type="text/html", @headers="Content-Disposition: form-data; name=\"upload[datafile]\"; filename=\"tositeconfig.html\"\r\nContent-Type: text/html\r\n", @tempfile=#<File:/tmp/RackMultipart20130213-26288-1r4gu37>>}, "commit"=>"Upload", "id"=>"men_of_fashion"}
   (1.2ms)  SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings` 
  User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` = 176 AND (users.status = 1) LIMIT 1
  Current user: cehovice (id=176)
  Project Load (0.9ms)  SELECT `projects`.* FROM `projects` WHERE `projects`.`identifier` = 'men_of_fashion' LIMIT 1
  EnabledModule Load (0.3ms)  SELECT name FROM `enabled_modules` WHERE `enabled_modules`.`project_id` = 1
  Rendered plugins/redmine_embedded/app/views/redmine_embedded/_upload.html.erb (6.5ms)
  Rendered plugins/redmine_embedded/app/views/redmine_embedded/index.html.erb within layouts/base (7.8ms)
  UserPreference Load (0.4ms)  SELECT `user_preferences`.* FROM `user_preferences` WHERE `user_preferences`.`user_id` = 176 LIMIT 1
  SQL (1.3ms)  SELECT `members`.`id` AS t0_r0, `members`.`user_id` AS t0_r1, `members`.`project_id` AS t0_r2, `members`.`created_on` AS t0_r3, `members`.`mail_notification` AS t0_r4, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `roles`.`id` AS t2_r0, `roles`.`name` AS t2_r1, `roles`.`position` AS t2_r2, `roles`.`assignable` AS t2_r3, `roles`.`builtin` AS t2_r4, `roles`.`permissions` AS t2_r5, `roles`.`issues_visibility` AS t2_r6 FROM `members` LEFT OUTER JOIN `projects` ON `projects`.`id` = `members`.`project_id` LEFT OUTER JOIN `member_roles` ON `member_roles`.`member_id` = `members`.`id` LEFT OUTER JOIN `roles` ON `roles`.`id` = `member_roles`.`role_id` WHERE `members`.`user_id` = 176 AND (projects.status<>9) ORDER BY projects.name
   (0.5ms)  SELECT COUNT(DISTINCT `versions`.`id`) FROM `versions` LEFT OUTER JOIN `projects` ON `projects`.`id` = `versions`.`project_id` WHERE (projects.id = 1 OR (projects.status <> 9 AND ( versions.sharing = 'system' OR (projects.lft >= 99 AND projects.rgt <= 132 AND versions.sharing = 'tree') OR (projects.lft < 99 AND projects.rgt > 132 AND versions.sharing IN ('hierarchy', 'descendants')) OR (projects.lft > 99 AND projects.rgt < 132 AND versions.sharing = 'hierarchy'))))
  Tracker Load (0.1ms)  SELECT `trackers`.* FROM `trackers` WHERE `trackers`.`id` IN (2)
  IssuePriority Load (0.2ms)  SELECT `enumerations`.* FROM `enumerations` WHERE `enumerations`.`type` IN ('IssuePriority') AND `enumerations`.`is_default` = 1 ORDER BY enumerations.position ASC LIMIT 1
   (0.2ms)  select version from schema_migrations where version like '%-redmine_backlogs'
  CACHE (0.0ms)  SELECT `trackers`.* FROM `trackers` WHERE `trackers`.`id` IN (2)
  CACHE (0.0ms)  SELECT `enumerations`.* FROM `enumerations` WHERE `enumerations`.`type` IN ('IssuePriority') AND `enumerations`.`is_default` = 1 ORDER BY enumerations.position ASC LIMIT 1
   (0.3ms)  select version from schema_migrations where version like '%-redmine_backlogs'
  Wiki Load (0.3ms)  SELECT `wikis`.* FROM `wikis` WHERE `wikis`.`project_id` = 1 LIMIT 1
   (0.2ms)  SELECT COUNT(*) FROM `boards` WHERE `boards`.`project_id` = 1
  Repository Load (2.7ms)  SELECT `repositories`.* FROM `repositories` WHERE `repositories`.`project_id` = 1 AND (is_default = 1) LIMIT 1
Completed 200 OK in 221ms (Views: 192.1ms | ActiveRecord: 9.8ms)

此:

gem env

得到我:

RubyGems Environment:                                                                                                                                                              
  - RUBYGEMS VERSION: 1.8.25                                                                                                                                                       
  - RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]                                                                                                                 
  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p385                                                                                                                    
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p385/bin/ruby                                                                                                                
  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p385/bin                                                                                                                  
  - RUBYGEMS PLATFORMS:                                                                                                                                                            
    - ruby                                                                                                                                                                         
    - x86_64-linux                                                                                                                                                                 
  - GEM PATHS:                                                                                                                                                                     
     - /usr/local/rvm/gems/ruby-1.9.3-p385                                                                                                                                         
     - /usr/local/rvm/gems/ruby-1.9.3-p385@global                                                                                                                                  
  - GEM CONFIGURATION:                                                                                                                                                             
     - :update_sources => true                                                                                                                                                     
     - :verbose => true                                                                                                                                                            
     - :benchmark => false                                                                                                                                                         
     - :backtrace => false                                                                                                                                                         
     - :bulk_threshold => 1000                                                                                                                                                     
  - REMOTE SOURCES:                                                                                                                                                                
     - http://rubygems.org/

在日志/制作中没有错误。

更新:

我设法上传了一个zip文件。但它并没有解开自己。我将在github上为该项目提交一张票。

1 个答案:

答案 0 :(得分:0)

运气不好。 cannot load such file -- dispatcher是一个插件的症状,尚未升级为与Redmine 2.x一起使用。你不需要疯狂的Ruby技能来自己做;见http://www.redmine.org/boards/3/topics/31445