0

I have a Ruby on Rails application I'm using Ruby 1.9 and Rails 2.3.4 and I want users to upload videos so I installed Paperclip gem but I'm getting this error from Rack. The fact that it says it's "invalid byte sequence" makes me suspect that it's from Ruby 1.9.

any ideas?

Thanks,

Tam

Rendering posts/new
Rendered posts/_form (4.5ms)
Rendered layouts/_footer (13.5ms)
Completed in 238ms (View: 161, DB: 8) | 200 OK [http://localhost/posts/new]
/!\ FAILSAFE /!\  2009-09-25 17:26:06 -0700
  Status: 500 Internal Server Error
  invalid byte sequence in US-ASCII
    /Users/tammam56/.gem/ruby/1.9.1/gems/rack-1.0.0/lib/rack/utils.rb:324:in `=~'
    /Users/tammam56/.gem/ruby/1.9.1/gems/rack-1.0.0/lib/rack/utils.rb:324:in `block in parse_multipart'
    /Users/tammam56/.gem/ruby/1.9.1/gems/rack-1.0.0/lib/rack/utils.rb:319:in `loop'
    /Users/tammam56/.gem/ruby/1.9.1/gems/rack-1.0.0/lib/rack/utils.rb:319:in `parse_multipart'
    /Users/tammam56/.gem/ruby/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:141:in `POST'

The form:

<% form_for @post, :html => {:multipart => true} do |f| %>
    <table width='100%' border="1">
        <tr>
            <td colspan="2">
                <h2>Post your Story</h2>
            </td>
        </tr>   
        <tr>
            <td nowrap="nowrap" width="20%">
                <p class="new_post_labels">I'm single bacause </p>
                <div id='ErrorMessage_title'></div>
            </td>
            <td>
                <%= f.text_field :title, :class => "grayInput fromInputPost", :maxLength =>100, :size => "50" %>
            </td>       
        </tr>   
        <tr>
            <td nowrap="nowrap" width="20%" valign="top">
                <p class="new_post_labels">Story Details (maximum 500 characters) </p>
                <div class="char_counter_new" id='actual_msg_count'>0/500</div>
                <div id='ErrorMessage_description'></div>               
            </td>
            <td>
                <%= f.text_area :description, :id => 'the_message_textarea', :size => "45x5", :class => "grayInput fromInputPostArea", :onkeyup => "calculate_msg_char_counter();", :id => "the_message_textarea" %>                                        
            </td>       
        </tr>       
        <tr>
            <td nowrap="nowrap" width="20%">
                <p class="new_post_labels">Video URL(optional - 90 seconds max)</p>
            </td>
            <td>
                <%= f.file_field :video %>
                <%= f.text_field :video_link, :class => "grayInput fromInputPost", :maxLength =>255, :size => "50" %>
            </td>       
        </tr>
        <tr>
            <td>
            </td>
            <td align="left" nowrap="nowrap">
                <p class="new_post_labels"><%= f.check_box :is_notify_when_comment %>Email me when someone comments on my story</p>
            </td>
        </tr>   
        <tr>
            <td></td>
            <td>
                <input type="button" value="Submit the Story" class="btnSubmitNewUser" onClick="validate_fields(this.form);" />&nbsp;
            </td>
        </tr>
    </tabl

e>

Tam
  • 11,872
  • 19
  • 69
  • 119
  • Does your form has enctype attribute? – Eimantas Sep 26 '09 at 04:09
  • Can you post your form? I've run across issues with Rack and multipart forms that don't have any form inputs. Could be something like that... – Doug R Sep 26 '09 at 04:20
  • @Eimantar: I'm not quite sure what is enctype. Can you please explain? @Doug R: I edited the post and entered the form code, my form has inputs as you can, you think I'm doing something wrong? Thanks – Tam Sep 26 '09 at 04:55
  • 1
    My answer's below, but as an interesting sidenote, I googled for "rails 1.9 paperclip", and this question was the top result less than an hour after the question was posted...the second result was the answer I posted. – Doug R Sep 26 '09 at 05:06

1 Answers1

1

Looks like there's an answer here:

http://rubynyc.wordpress.com/ruby-1-9-1/paperclip-triggering-a-invalid-byte-sequence-in-us-ascii/

Essentially, the fix is to uninstall the version of Rack that comes with Rails and reinstall the gem from github. Of course, you might want to try this on another machine first... :-)

Doug R
  • 5,749
  • 2
  • 28
  • 32
  • Fantastic....I think I should work better on my Googling skills..I tried searching for quite a bit before posting but couldn't find that link...thanks – Tam Sep 26 '09 at 05:21