I've got a database with tables. I wish to produce a model during my Rails application from existing table. When i know, such functionality can be obtained, and it is done the following:

script/generate scaffold model_name --skip-migration

Obviously, i defined my database in database.yml file. Scaffold produced for me personally one with controller and sights. My table title isn't as it should be for Rails(it's incorrect, not following conventions), i added set_table_title to my controller. But, after i am calling the index method, on my small page i've only group of # symbols, although not an information from database. During my index.html.erb i've only produced code by scaffold. How do i print my database data?

Perhaps you have produced a schema file out of your existing database? Should you run the command

rake db:schema:dump

after which re-generate your scaffold this will repair the problem.

Furthermore you may decide to take a look at Dr Nic's Magic Model generator. This can generate models for all your existing tables and try to guess the associations. This can most likely not work in case your table naming isn't understandable by rails.


I don't generally make use of the default scaffold however have examined this myself also it seems when you skip the migration and don't pass any column title/type pairs then your scaffold generator won't create anything within the template to render the posts.

You've two options here either

  1. Pass within the column title pairs in addition to skip-migration or
  2. Download Ryan Bates Nifty Scaffold generator developing the scaffold using the column names even when you specify --skip-migration