Ok i used <%= image_tag builder.object.photo.url(:small) %> instead of
<%= image_tag :photo.url(:small) %>
Seems to work now

On Aug 26, 6:29 pm, Christian Fazzini <[email protected]>
wrote:
> My form partial is being used to create new, and also for editing.
>
> <% form_for @deal, :html => { :multipart => true } do |f| %>
>   <%= f.error_messages %>
>
>   <p>
>     <%= f.label :city_id %>
>     <%= f.collection_select :city_id, City.find(:all), :id, :name,
> { :prompt => 'Select a city' }, {:class => 'foobar'} %>
>   </p>
>   <p>
>     <%= f.label :title %><br />
>     <%= f.text_field :title %>
>   </p>
>   <p>
>     <%= f.label :description %><br />
>     <%= f.text_area :description %>
>   </p>
>   <p>
>     <%= f.label :price %><br />
>     <%= f.text_field :price %>
>   </p>
>   <p>
>     <%= f.label :value %><br />
>     <%= f.text_field :value %>
>   </p>
>   <p>
>     <%= f.label :discount %><br />
>     <%= f.text_field :discount %>
>   </p>
>   <p>
>     <%= f.label :savings %><br />
>     <%= f.text_field :savings %>
>   </p>
>   <p>
>     <%= f.label :goal %><br />
>     <%= f.text_field :goal %>
>   </p>
>   <p>
>     <%= f.label :countdown %><br />
>     <%= f.text_field :countdown %>
>   </p>
>   <p>
>     <%= f.label :purchased %><br />
>     <%= f.text_field :purchased %>
>   </p>
>
>   <% f.fields_for :photos do |builder| %>
>     <p class="fields">
>       <%= builder.label :photo, "Photos" %><br />
>
>       <% if [email protected]_record? %>
>
>         <%= image_tag :photo.url(:small) %>
>       <% else %>
>         <%= builder.file_field :photo %>
>       <% end %>
>
>       <br />
>
>       <!--
>       <%= builder.check_box :_destroy %>
>       <%= f.label :destroy, "Remove photo" %>
>       -->
>
>       <%= builder.hidden_field :_destroy %>
>       <%= link_to_function "remove", "remove_fields(this)" %>
>     </p>
>   <% end %>
>
>   <p><%= link_to_add_fields "Add photos", f, :photos %></p>
>
>         <% f.fields_for :features do |builder| %>
>           <p class="fields">
>             <%= builder.label :description, "Features" %><br />
>                         <%= builder.text_area :description, :rows => 3 %><br 
> />
>
>       <!--
>       <%= builder.check_box :_destroy %>
>       <%= f.label :destroy, "Remove description" %>
>                         -->
>
>                         <%= builder.hidden_field :_destroy %>
>       <%= link_to_function "remove", "remove_fields(this)" %>
>                 </p>
>         <% end %>
>
>         <p><%= link_to_add_fields "Add feature", f, :features %></p>
>
>   <p>
>     <%= f.submit 'Save' %>
>   </p>
> <% end %>
>
> --------------
>
> Im having trouble with the following lines:
>
>       <% if [email protected]_record? %>
>
>         <%= image_tag :photo.url(:small) %>
>       <% else %>
>         <%= builder.file_field :photo %>
>       <% end %>
>
>       <br />
>
> When I am creating a new deal. The file_field appears appropriately.
> But if I am editing a deal with existing photos, I cant get <%=
> image_tag :photo.url(:small) %> to show...
>
> All this is inside the <% f.fields_for :photos do |builder| %> loop.
> Which is needed for <%= builder.hidden_field :_destroy %> and <%=
> link_to_function "remove", "remove_fields(this)" %>, which are meant
> to remove photos when the form is submitted.
>
> How can I get all this to work?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to