Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Missing Block #7

Closed
nhocki opened this issue Apr 28, 2010 · 5 comments
Closed

Missing Block #7

nhocki opened this issue Apr 28, 2010 · 5 comments

Comments

@nhocki
Copy link
Contributor

nhocki commented Apr 28, 2010

Hello, I get a Missing Block error when I try to use nested_form_for instead of form_for

<% nested_form_for @project, :html => { :multipart => true } do |f| %>

The most wired thing is that it happens when I try to submit something that is not valid and not when I first render the "new" action.

@nhocki
Copy link
Contributor Author

nhocki commented Apr 28, 2010

Ok, I "found" the problem but I have no idea how to solve it:

I have a select list inside my nested model. So the form has "f.select ..." but when I edit my object, it won't get selected in the one that it was stored. So I just added a
for c in competences
fields_for :competences, c do |builder|
render partial
end
end

And there is where the missing block error appears.

Any help?
Thanks

@nhocki
Copy link
Contributor Author

nhocki commented May 12, 2010

Just had to use the f.object method to get what I wanted...

@findchris
Copy link

Can you elaborate on your solution? I'm having the same problem.
Thanks.

@nhocki
Copy link
Contributor Author

nhocki commented Sep 1, 2010

Ok, what I have is this:
#_form.html.erb
<% f.fields_for :webToolUrls do |builder| %>
<%= render 'webToolUrl_fields', :f => builder %>
<% end %>

  #_webToolUrl_fields.html.erb
  <% field_set_tag "Herramienta  Web 2.0", :class => "formFieldSet" do %> <br/>
     # Some other fields here ...
     <%= f.select :webTool_id, options_from_collection_for_select(WebTool.all, :id, :name, f.object.webTool_id) %> <br />  # notice the f.object.webTool_id
  <% end %>

I hope that helps

@findchris
Copy link

That helps.
Thanks!

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

No branches or pull requests

2 participants