I created a new action knowledges
in my controller responsabilities
and created a view called nested_knowledges
. I made the action render this view. I put the following code in this view:
<%= form_tag edit_responsability_path do -%>
<% for @responsability in Responsability.find(:all)-%>
<% for knowledge in Knowledge.find(:all) %>
<%= check_box_tag "responsability[knowledge_ids][]", knowledge.id, @responsability.knowledges.include?(knowledge) %>
<%= knowledge.nome %>
<br/>
<% end %>
<% end %>
<div class="actions">
<%= submit_tag l(:send) %>
<br/>
</div>
It renders a has_and_belongs_to_many relationship between the Responsibilities and Knowledges tables.
I put form_tag, because if I create form_for it displays an error. But when I click on my button to send, the Knowledges records that that Responsability has, it says there is no route, as in the error below:
Started POST "/responsabilities/1/edit" for 127.0.0.1 at 2014-06-03 12:00:24 -0300
ActionController::RoutingError (No route matches [POST] "/responsabilities/1/edit"):
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:21:in 'call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in 'call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in 'call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in 'block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in 'tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in 'call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in 'call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in 'call'
rack (1.4.5) lib/rack/runtime.rb:17:in 'call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in 'call'
rack (1.4.5) lib/rack/lock.rb:15:in 'call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in 'call'
railties (3.2.13) lib/rails/engine.rb:479:in 'call'
railties (3.2.13) lib/rails/application.rb:223:in 'call'
rack (1.4.5) lib/rack/content_length.rb:14:in 'call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in 'call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in 'service'
c:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:138:in 'service'
c:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:94:in 'run'
c:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:in 'block in start_thread'
What do I need to do to get these records sent?