Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Remove record with composite P...

Replytotopic

Remove record with composite PK

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 14
Sign in to rate this post

Hello

I have a table with the following primary key: (user_id, class_id).
In the table model file I have specified the PK:

self.primary_key = “user_id, class_id”

Now, in the controller I created a method to remove a record of that table.

When the PK is normal (ie, not a composite one), it is only necessary to write a line like the following:

Model.delete(id)

Since my model have two fields in the PK, how can I do that?

Thanks
regards

 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

I guess you could take a look at Dr Nic’s composite primary keys gem: http://compositekeys.rubyforge.org/

 
Profile

Authority 0
Posting Rating 14
Sign in to rate this post

Nice.
Thanks!

Replytotopic

Other Recent Topics

Ask a Rails expert : json gem error

Ask a Rails expert : Problem with break

Ask a Rails expert : activesupport string first method error

Ask a Rails expert : url_for broken ?

Ask a Rails expert : map.routes.rb pls help

Ask a Rails expert : how to h tag in controller

Ask a Rails expert : Problem with Restful routing and partial form

Ask a Rails expert : will_paginate, search and ajax

Ask a Rails expert : captcha

Ask a Rails expert : Mass Deletes in Admin Section

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel