Jump to content

The ultimate community for Ruby on Rails developers.


Photo

How to set table name in rails 4

rails 4 table name

  • Please log in to reply
2 replies to this topic

#1 Vell

Vell

    Dispatcher

  • Members
  • 42 posts
  • LocationWashington, DC

Posted 18 February 2014 - 12:49 AM

I can't seem to find any documentation on how to set the table name in a model. In rails 3 it was 

set_table_name 'name'

I have seen where some are using

self.table_name = 'name'

Neither work for me in rails for. Can anyone show me the right code to use or where some good documentation is on this?

 

As a bonus to the above question, I would I go about digging into rails active record code to find this out?



#2 Bharat Soni

Bharat Soni

    Dispatcher

  • Members
  • 53 posts
  • LocationAhmedabad

Posted 18 February 2014 - 05:12 AM

Hey buddy it should be work, because these is the way to set table name in rails 4

class Countries < ActiveRecord::Base
self.table_name = 'cc'
...
end

Fun with Ruby on Rails


#3 Vell

Vell

    Dispatcher

  • Members
  • 42 posts
  • LocationWashington, DC

Posted 19 February 2014 - 06:23 AM

I have decided to go a different way. I think I was creating too much work for myself trying to name space using scaffolding. So I will do this manually so that I can use the same table with 2 different controllers.







Also tagged with one or more of these keywords: rails 4, table name

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users