03 Apr 2012, 09:58

John Lane (6 posts)

I have this failure when running the tests after adding the email support in H1.

The book states “We don’t even need to modify the partial, because the existing one we already have will do just fine”

However, in an earlier “playtime”, a decrement button was added to the cart, so I have in my _line_item.html.erb partial a “button_to”.

I believe the error occurs becasue buttons aren’t supported in emails.

I see three options:

  1. Identify inside the partial (_line_item.html.erb) when it’s used from action mailer and exclude the button in that instance.

  2. Have a different _line_item.html.erb for use by the mailer.

  3. Take the button out of the cart and put it somewhere else.

I’d like to understand how to do (1) and (2) but it isn’t clear to me. Any pointers ?

22 Apr 2012, 09:29

Tom Gillett (1 post)

I had the same problem, I fixed it by:

(1) duplicating my _line_item.html.erb partial as _line_item_simple.html.erb (2) stripping out any additional markup - buttons, etc (3) rendering it in order_shipped.html.erb with the following:

<%= render :partial => 'line_items/line_item_simple', :collection => @order.line_items, :as => :line_item %>

Hope that helps! Tom.

21 Nov 2012, 13:56

Jack Chen (2 posts)

You can implement (1) in _line_item.html.erb <% if @order.nil? %> <td><%= button_to “Decrease”, line_item, :remote => true, :method => :delete, :confirm => “Are you sure?” %></td> <% end %>

  You must be logged in to comment