Hi Matt, Actually I am trying to connect to already existing DB where mentioned table is readily available. I just need to read it all the time or occasionally write it but I do not create it from my app. The primary key of the table is varchar. I can do nothing about that and if i do not declare it into my model, it will assume a primary key 'id' in the table. Is there any better way here?
PS: i cannot see your posting on ruby-forum. Will it take LOTS of time for that to appear on the site or something else? -Kalpesh On Sat, Nov 14, 2009 at 10:54 PM, Matt Jones <[email protected]> wrote: > > Somewhat unrelated, but if you're creating a new, "simple" Rails app, > why are you tangling with set_table_name and a noninteger primary key? > Working against the Rails conventions will cause no end of trouble, > especially if you're just starting out... > > --Matt Jones > > On Nov 13, 4:00 am, Kalpesh1 Patel <[email protected]> > wrote: >> I was creating this simple rail application. my controller method looks >> like this: >> ------- >> def create() >> @simple = Simple.new(params[:simple]) ##params coming from view >> @simple.save >> end >> ------- >> >> And my model class "Simple" as below: >> >> ------- >> class Simple < ActiveRecord::Base >> set_table_name "name_desc_table" >> set_primary_key "name" >> >> before_create :init_name >> >> private >> def init_name(cname) >> self.name = cname >> end >> end >> ------- >> >> When I run this in browser, it throws error "Wrong number of arguments >> (0 for 1)". Obviously, my method "init_name" expects one parameter and >> it doesn't find any while called(by controller??). Basically I want to >> send this 'cname' variable from controller to model. Can anybody tell me >> what can I do in controller method so that 'cname' variable is passed >> when callback method is called? >> >> Thanks, >> -Kalpesh >> -- >> Posted viahttp://www.ruby-forum.com/. > > > -- Why so serious? --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

