Dear all In rails, the are some magical column such as id, created_at, updated_at can make things easier. However, within my organization, due to whatever reason, the data type identity is not allowed to use. So, the magical id column cannot be used in my rails project. I know that there is some actions rely on the like http://localhost:3000/controller/action/123, where 123 is the :id...and in edit_path(:id), It seems that without the id column I cannot perform these actions.. Am I right? Should I change other web framework in my project (but I love rails ^_^)? Or any workaround available in rails if my table without the id column? Is it really a matter for the CRUD action without id column? Please give me some advices. Thank you. Valentino -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 17 Feb 2009, at 10:10, Valentino Lun wrote:> > Dear all > > In rails, the are some magical column such as id, created_at, > updated_at > can make things easier. > > However, within my organization, due to whatever reason, the data type > identity is not allowed to use. So, the magical id column cannot be > used > in my rails project. I know that there is some actions rely on the > like > http://localhost:3000/controller/action/123, where 123 is > the :id...and > in edit_path(:id), It seems that without the id column I cannot > perform > these actions.. Am I right? >Rails assumes very much that there is a primary key (as in a single column that uniquely identifies rows i don''t think it actually cares whether it is labelled a primary key in the database), you don''t have to call it id though (see set_primary_key). I''m not sure what would happen if the primary wasn''t auto increment (or associated with a sequence etc.) but you could give it a go. Fred> Should I change other web framework in my project (but I love rails > ^_^)? Or any workaround available in rails if my table without the id > column? Is it really a matter for the CRUD action without id column? > > Please give me some advices. > > Thank you. > > Valentino > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can use a UUID instead... never used it myself though. google "rails uuid" On Feb 17, 5:10 am, Valentino Lun <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Dear all > > In rails, the are some magical column such as id, created_at, updated_at > can make things easier. > > However, within my organization, due to whatever reason, the data type > identity is not allowed to use. So, the magical id column cannot be used > in my rails project. I know that there is some actions rely on the likehttp://localhost:3000/controller/action/123, where 123 is the :id...and > in edit_path(:id), It seems that without the id column I cannot perform > these actions.. Am I right? > > Should I change other web framework in my project (but I love rails > ^_^)? Or any workaround available in rails if my table without the id > column? Is it really a matter for the CRUD action without id column? > > Please give me some advices. > > Thank you. > > Valentino > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi there, I have worked with legacy databases that had no ''id'' column but had a different column as primary key. You only need to add the following code to your models: self.primary_key = ''your_primary_key_column_here'' I hope this helps. Pepe On Feb 17, 5:10 am, Valentino Lun <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Dear all > > In rails, the are some magical column such as id, created_at, updated_at > can make things easier. > > However, within my organization, due to whatever reason, the data type > identity is not allowed to use. So, the magical id column cannot be used > in my rails project. I know that there is some actions rely on the likehttp://localhost:3000/controller/action/123, where 123 is the :id...and > in edit_path(:id), It seems that without the id column I cannot perform > these actions.. Am I right? > > Should I change other web framework in my project (but I love rails > ^_^)? Or any workaround available in rails if my table without the id > column? Is it really a matter for the CRUD action without id column? > > Please give me some advices. > > Thank you. > > Valentino > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---