i have table pro_categories and i am handle add update from admins controller but can not destroy record from there i mean using admin controller <div> <h3 align="center">Product Category</h3> <table align="center"> <tr> <th>Category Title</th> </tr> <% @pro_categories.each do |p| %> <tr align="center"> <td><%= p.pcate_name%></td> <td><%= link_to_remote(''Show'',:update => "mcont", :url => {:controller => :admins, :action => :cateshow},:with => "''id=#{p.id}''")%></td> <td><%= link_to_remote(''Edit'',:update => "mcont", :url => {:controller => :admins, :action => :catedit},:with => "''id=#{p.id}''") %></td> ================================== <td><%= link_to ''Destroy'', p, :confirm => ''Are you sure?'', :method => :delete %></td> ============================ </tr> <%end%> <tr><td colspan="3" align="center"><%= link_to_remote(''New'',:update => "mcont", :url => {:controller => :admins, :action => :cateadd } )%> <%= link_to ''Back'',admins_path %></td></tr> </table> </div> above my file i am display record using pro_categories table so it''s controller p define if any idea about it i want to delete record in p(pro_categories) table -- Posted via http://www.ruby-forum.com/.
On Aug 11, 2:23 pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> i have table pro_categories and i am handle add update from admins > controller but can not destroy record from there i mean using admin > controller >What happens when you try ? Fred
Frederick Cheung wrote:> On Aug 11, 2:23�pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> i have table pro_categories and i am handle add update from admins >> controller but can not destroy record from there i mean using admin >> controller >> > What happens when you try ? > > Fredit''s url is like this http://127.0.0.1:3000/pro_categories/1 but i have no pro_categories controller so i want to define this delete method in admin controller and i want to delete pro_categories''s record.(actually i have procategorie model.) -- Posted via http://www.ruby-forum.com/.
On Aug 11, 2:49 pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Aug 11, 2:23 pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > >> i have table pro_categories and i am handle add update from admins > >> controller but can not destroy record from there i mean using admin > >> controller > > > What happens when you try ? > > > Fred > > it''s url is like thishttp://127.0.0.1:3000/pro_categories/1but i have > no pro_categories controller so i want to define this delete method in > admin controller and i want to delete pro_categories''s record.(actually > i have procategorie model.)either fiddle with your routes so that you have an admin namespace (so that you can do stuff like link_to ''destroy'', admin_product_path (p), ...) or don''t use the restful stuff. Fred> -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Aug 11, 2:49�pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> >> it''s url is like thishttp://127.0.0.1:3000/pro_categories/1but i have >> no pro_categories controller so i want to define this delete method in >> admin controller and i want to delete pro_categories''s record.(actually >> i have procategorie model.) > > either fiddle with your routes so that you have an admin namespace (so > that you can do stuff like link_to ''destroy'', admin_product_path > (p), ...) or don''t use the restful stuff. > > Fredok dear i have to fix this problem in destroy code like this <%= link_to ''Destroy'',:confirm => ''Are you sure?'',:action => ''destroycat'',:id => p.id, :method => :delete %></td> p.id it take only id only p take pro_categories so that if we r make such type it is possible and controller file like this def destroycat @pro_categorie = ProCategorie.find(params[:id]) @pro_categorie.destroy respond_to do |format| format.html { redirect_to(admins_url) } format.xml { head :ok } end end -- Posted via http://www.ruby-forum.com/.