On Wednesday, June 18, 2014 7:31:03 AM UTC-4, Ruby-Forum.com User wrote:
>
> I have nested resources
>
> resources :dicts do
> resources :cards
> end
>
> and in my form
>
> form_for [@dict,@card] do |f|
>
> I have the following button:
>
> <%= f.submit('LIST ALL', url: dict_cards_path(@dict.id),
> class:'kanren_button', name:'list_all', method: :get) %>
>
> The generated HTML code is:
>
> <input class="kanren_button" method="get" name="back_to_list"
> type="submit" url="/dicts/6/cards" value="BACK TO LIST" />
>
> I would expect that clicking this button would call Card.index, but I
> get instead the error message
>
> The action 'update' could not be found for CardsController
>
> It is correct that I don't have a CardsController.update yet, but I
> don't think I should need one at this point.
>
> The output from 'rake routes|grep card' looks fine for me:
>
> dict_cards GET /dicts/:dict_id/cards(.:format)
> cards#index
> POST /dicts/:dict_id/cards(.:format)
> cards#create
> new_dict_card GET /dicts/:dict_id/cards/new(.:format) cards#new
> edit_dict_card GET /dicts/:dict_id/cards/:id/edit(.:format)
> cards#edit
> dict_card GET /dicts/:dict_id/cards/:id(.:format)
> cards#show
> PATCH /dicts/:dict_id/cards/:id(.:format)
> cards#update
> PUT /dicts/:dict_id/cards/:id(.:format)
> cards#update
> DELETE /dicts/:dict_id/cards/:id(.:format)
> cards#destroy
>
> What did I do wrong?
>
> --
> Posted via http://www.ruby-forum.com/.
>
The method and url parameters you have in the submit helper that show up in
the output are going to be ignored, they aren't valid parameters for
submit. Those items are actually defined above in the html form tag (which
is generated from your form_for statement). My guess is that if you look
at the log, this is coming across with an action of PATCH or PUT.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/c52ce958-6f19-4684-af39-864051735c9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.