I´m not sure that you can use the collection_select with a link, better use
a form
try something like:
VIEW
<%= form_tag( :controller =>"Catvalues", :action => "detroy", method =>
"delete" do %>
<%= collection_select(:catvalue, :id, @catvalues, :id, :v_name, {}, class:
'drop-down')%>
<%= submit_tag("Destroy")
<% end %>
´CONTROLLER
def destroy
@catvalue_del = Catvalue.find(catvalues_params[:id])
@catvalue_del.destroy
redirect_to catvalues_path
end
def catvalues_params
params[:catvalues].permit(:id)
end
El jueves, 10 de abril de 2014 09:27:30 UTC+2, santu47 escribió:
>
> How to delete a drop down select value by using link_to option.
>
> *My code is:*
>
> *index.html.erb*
>
> <%= collection_select(:catvalue, :id, @catvalues, :id, :v_name, {}, class:
> 'drop-down')%>
> <%= link_to 'Destroy', {:catvalue => :id},method: :delete, data: { confirm:
> 'Are you sure?' } %>
>
> and my
>
> *controller is:*
>
> class CatvaluesController < ApplicationController
> def index
> @catvalue = Catvalue.new
> @catvalues = Catvalue.all
> @categories = Category.all
> end
>
> def destroy
> @catvalue_del = Catvalue.find(params[:id])
> @catvalue_del.destroy
> redirect_to catvalues_path
> endend
>
> but its not working
> please help me..
>
> Thanks in advance
>
--
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/73fbf42a-311e-444e-be95-b76716a4e073%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.