Hi all, I have a table structure with me not having an id column. When I try to delete the row i get an error ''Unknown column "table.id"''. Can i do the action with any other method than destroy/delete? Or with the same method and any other conditions? Thanks. Sainaba. -- Posted via http://www.ruby-forum.com/.
sainaba sainu wrote:> Hi all, > > I have a table structure with me not having an id column. When I try to > delete the row i get an error ''Unknown column "table.id"''. Can i do the > action with any other method than destroy/delete? Or with the same > method and any other conditions? > > Thanks. > Sainaba.Check out the destroy_all method. It may well suit your needs. http://api.rubyonrails.org/classes/ActiveRecord/Base.html ~Ben -- Posted via http://www.ruby-forum.com/.
> Check out the destroy_all method. It may well suit your needs. > > http://api.rubyonrails.org/classes/ActiveRecord/Base.html > > ~BenYou may also use delete_all :D -- Posted via http://www.ruby-forum.com/.
sainaba sainu wrote:> Hi all, > > I have a table structure with me not having an id column. When I try to > delete the row i get an error ''Unknown column "table.id"''. Can i do the > action with any other method than destroy/delete? Or with the same > method and any other conditions? > > Thanks. > Sainaba.Change the line that looks up your record in the delete function to use your own primary key. instead of something like @item = Item.find(params[:id]) it will be something like @item = Item.find(params[:name]) or @item = Item.find_by_name(paranms[:name]) Depends on how you have your table set up. _Kevin -- Posted via http://www.ruby-forum.com/.