ruby - composite_primary_keys on Rails 4 Controller -


i trying use composite_primary_keys gem on application. made "enterprise" model have "related" , "branch" attributes. 2 composite pk.

class enterprise < activerecord::base   self.primary_key = :related, :branch end 

using rails console, can find first entreprise using e = enterprise.find([1,1]) without problem.

the thing is: can't make work on controller...

my show action, example:

@enterprise = enterprise.find(params[:id]) 

it gives me error:

couldn't find enterprise 'related,branch'=1,1

parameters: {"id" => "1, 1"}

what doing wrong?

params[:id] string - need create array out of it:

@enterprise = enterprise.find(params[:id].split(',').map(&:to_i)) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -