Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formtastic paperclip attribute detection generates wrong html #36

Closed
brainlag opened this issue Aug 20, 2009 · 5 comments
Closed

formtastic paperclip attribute detection generates wrong html #36

brainlag opened this issue Aug 20, 2009 · 5 comments

Comments

@brainlag
Copy link

Html generated with autodetection:

<li id="model_field_input" class="string required">
     <label for=model_field">Field<abbr title="required">*</abbr></label>
     <input type="text" value="/field/original/missing.png" size="50" name="model[field]" id="model_field"/>
</li>

Html generated whenn forced to :file (:as => :file)


  • Field*

  • @justinfrench
    Copy link
    Member

    What's the actual name of the file upload field? Can we see the code you're using to get this output?

    You're getting a "string" input rather than a "file" input because Formtastic doesn't think this field is a file upload field. There's some rudimentary checking in there (see @@file_methods config option and the code around line 1025), but without knowing the name of the attribute and some more stuff about your model, I can't write a decent (failing) test.

    @brainlag
    Copy link
    Author

    I think i should mention that I use Ruby 1.9.1. Not sure if this makes a difference, but I tried to run the specs last night and 95% of all testcases were failing.

    @justinfrench
    Copy link
    Member

    Pasting in DM from brainlag so all info is one one place:

    I think Formtastic thinks it is a "file" because the input box it generates with some text filled in. See the value attribute of the input field.

    Model:

    class Map < ActiveRecord::Base
    has_many :replays

    has_attached_file :image
    validates_attachment_presence :image
    validates_presence_of :name
    

    end
    View:

    <% semantic_form_for :map, :html => {:multipart => true}, :url => maps_path do |form| %>
    <% form.inputs do -%>
    <%= form.input :name %>
    <%= form.input :image %>
    <% end -%>
    <% form.buttons do -%>
    <%= form.commit_button 'Create' %>
    <% end -%>
    <% end %>

    @brainlag
    Copy link
    Author

    ok, i found what is wrong

    when you use semantic_form_for you should pass an instance variable and not a symbol
    because if you use a symbol the autodedection breaks

    so it is all my fault

    @justinfrench
    Copy link
    Member

    good know nothing serious was broken!

    This issue was closed.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants