0

First of all I watched Railscast #196 and Railscast #197.

I have also read this and a lot of other similar questions.

Im getting the following error:

Missing partial profils/compagny_fields, application/compagny_fields with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/home/me/www/Myapp/app/views"

It seems that its not a partial problem cause i can see the puts from my partial.

So on my models i have:

CompagnyModel: belongs_to :profil`

ProfilModel: has_many :compagnies, accepts_nested_attributes_for :compagnies

In my View I have:

<%= p.label :firstname, "firstname" %> <%= p.text_field :firstname %>

<%= p.label :lastname, "lastname" %> <%= p.text_field :lastname %>

<%= p.fields_for :compagnies do |n| %>
   <%= render 'compagnies_fields', :c => n %>
<% end %>
<%= link_to_add_fields "Add Compagny", p, :compagnies %> 
<% end %>

<%= f.submit "save" %>

Finally here is my partial:

<p class="fields">
  <%= c.label :name, "Compagny"%><br />
  <%= c.text_field :name %><br />
  <%= link_to_remove_fields "remove", c %><br />
  <% puts "-----!-!-!-!-!-!-!-!-DEBUG-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!------" %>   
</p>

3 Answers 3

0

Is that single quote on

CompagnyModel: belongs_to :profil`

in the actual model file?

Is the partial form being called saved in "profils/_compagny_fields.html.erb" or in "compagnies/_compagny_fields.html.erb"?

<%= p.fields_for :compagnies do |n| %>
  <%= render 'compagny_fields', :c => n %>
<% end %>

Try building the Profil.Compagnies model in the console to check that it is valid

new_profil = Profil.new
new_profil.compagnies.build

In the Profil_Controller I take it there is a variable @profil = Profil.new?

@profil = Profil.new
@profil.compagnies.build

Does the views/profil/new.html.erb (or views/profil/_form.html.erb if you're doing the forms in that way) have the form

<%= form_for(@profil) do |p| %>
0

I had the same error. You named your partial "compagny_fields" but you want to render 'compagnies_fields'. This was my problem, mayby it is yours too.

0
0

I solved this by changing this

render(association.to_s.singularize + "_fields", :f => builder)

to this

render(association.to_s , :f => builder)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.