Rails - Rendering an edit form partial within another partial -


i have table trying make bit more streamlined. in view (this view partial (_recipe_ingredient.html.erb), have following code, rendering partial not working:

<tr>   <td><%= recipe_ingredient.ingredient.name %></td>   <td><%= recipe_ingredient.ingredient.weight1*recipe_ingredient.quantity %></td>   <td><%= recipe_ingredient.ingredient.description1 %></td>   <td><%= recipe_ingredient.quantity %></td>   <td><%= render(:partial => 'recipe_ingredients/edit', :locals =>        {:recipe_ingredient=> recipe_ingredient}) %></td>   <td><%= link_to 'remove', recipe_ingredient, :confirm => 'remove ingredient      recipe?', :method => :delete %></td>   </tr> 

previously, using link_to edit recipe_ingredient follows (which worked fine), not have user go page edit - instead want form part of table:

<td><%= link_to 'edit quantity', edit_recipe_ingredient_path(recipe_ingredient) %></td> 

the edit partial (which new non-working code calls) looks like:

<h1>editing recipe_ingredient</h1> <%= render 'recipe_ingredients/form', :recipe_ingredient => @recipe_ingredient %> 

and standard form partial looks like:

<%= form_for(@recipe_ingredient) |recipe_ingredient| %>   <% if @recipe_ingredient.errors.any? %>     <div id="error_explanation">       <h2><%= pluralize(@recipe_ingredient.errors.count, "error") %> prohibited           recipe_ingredient being saved:</h2>        <ul>       <% @recipe_ingredient.errors.full_messages.each |msg| %>         <li><%= msg %></li>       <% end %>       </ul>     </div>   <% end %>      <div class="field">     <%= recipe_ingredient.label :quantity %><br />     <%= recipe_ingredient.number_field :quantity %>   </div>   <div class="actions">     <%= recipe_ingredient.submit %>   </div> <% end %> 

mainly, i'm confused why works using link_to, can't render partial. error i'm getting undefined method `model_name' nilclass:class in first line of form partial.

i've tried taking "@" off @recipe_ingredient in form partial, doesn't work either.

thanks in advance help.

just create object @recipe_ingredient in action think edit action.

@recipe_ingredient = recipeingredient.find_by_id(params[:id) 

hope work fine.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -