Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-06 Thread kenatsun
Comments inserted below. Did the generator add the validations for that attribute? Did it add the code in the toy.rb that implements the business logic involving that attribute? Did it add the attribute to the views that do not just consist of the simplistic tables and so on generated by

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-06 Thread Colin Law
On 5 June 2015 at 22:21, kenatsun kenat...@gmail.com wrote: All of the changes were to files that specifically mentioned the model's attributes (aka the table's columns), and all the changes consisted of adding a mention of the new column. For example, the auto-edit of show.json.jbuilder when

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-05 Thread Colin Law
On 5 June 2015 at 21:25, kenatsun kenat...@gmail.com wrote: ... Were not all of these 9 edits necessary to weave the new database column into my app? Diff the files and see what the changes were. Colin -- You received this message because you are subscribed to the Google Groups Ruby on

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-05 Thread kenatsun
Scott Colin ~ Perhaps this conversation has reached the end of its useful life. But in case there still is anything left to be learned, let me respond to a couple of your comments. Why on earth would you keep re-generating scaffolds over and over??? [Scott] Because generators, when they

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-05 Thread kenatsun
All of the changes were to files that specifically mentioned the model's attributes (aka the table's columns), and all the changes consisted of adding a mention of the new column. For example, the auto-edit of *show.json.jbuilder* when I added the *size *attribute changed json.extract! @toy,

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-05 Thread kenatsun
All of the changes were to files that specifically mentioned the model's attributes (aka the table's columns), and all the changes consisted of adding a mention of the new column. For example, the auto-edit of *show.json.jbuilder* when I added the *size *attribute changed json.extract! @toy,

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-04 Thread kenatsun
Yeah, I figured something like that was the case. Probably that's the case with most/all Rails generators (like most of the generators in the world) - they're good for a one-time kick-start, but not much good after that. Still, a generator that could write on something other than a blank slate

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-04 Thread Colin Law
On 4 June 2015 at 21:21, kenatsun kenat...@gmail.com wrote: ... However: This process has only a limited ability to update the Rails objects to handle the database change while preserving manually entered changes to them. Specifically: For each Rails file where the new (generated) version

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-04 Thread kenatsun
*Next step*: I have succeeded in adding a column to a database table, then using the generator tools to update the Rails objects that implement that model. The process, which I share for what it's worth to others, is: 1. Add attribute *toys.color* (text): sqlite ALTER TABLE toys ADD

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-01 Thread Nugi Nugraha
I think you just need to create Toy model and then use scaffold controller http://stackoverflow.com/questions/493/using-rails-generate-scaffold-when-model-already-exists On Mon, Jun 1, 2015 at 7:06 AM, kenatsun kenat...@gmail.com wrote: My next question is whether it is possible to sue the

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-01 Thread Hassan Schroeder
On Sun, May 31, 2015 at 5:06 PM, kenatsun kenat...@gmail.com wrote: 10. An odd note is that there still is no schema.rb file in x/db/. If this is what Rails uses as its database catalog, is the lack of it going to cause trouble down the road? Possibly, but you can use `rake db:schema:dump`

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-01 Thread kenatsun
Thank you, byakugie* ~* Your link led me to the gem schema-to-scaffold, which enabled the following scenario: The aim is to get all the components generated automatically, but based on the database schema. I did it my using the gem *schema_to_scaffold, *which simply generates a script (one

Re: [Rails] Re: How to generate Rails models from database schemas

2015-06-01 Thread kenatsun
Thanks, Hassan ~ The rake command does the job of building (and updating) schema.rb. ~ Ken On Monday, June 1, 2015 at 2:06:45 PM UTC-4, Hassan Schroeder wrote: On Sun, May 31, 2015 at 5:06 PM, kenatsun kena...@gmail.com javascript: wrote: 10. An odd note is that there still is no

[Rails] Re: How to generate Rails models from database schemas

2015-05-31 Thread kenatsun
Yaay! I'm happy to report success with my first attempt to make a Rails app that works from an existing database. This first experiment used (a) the simplest instructions I could find (basically, Hassan's); (b) a streamlined version of the Getting Started Guide process for setting up a

[Rails] Re: How to generate Rails models from database schemas

2015-05-23 Thread kenatsun
Thanks a million to Scott, Hassan, Colin, for this rich feast of possibilities! It's gonna take me some time to digest. Then I'll be back with the solutions I'm finding and/or with more questions. ~ Ken On Friday, May 22, 2015 at 3:44:34 PM UTC-4, kenatsun wrote: I'm evaluating Rails (vs

[Rails] Re: How to generate Rails models from database schemas

2015-05-22 Thread Elizabeth McGurty
You don't always have to work with Rails functionality to utilize a database, not sure always true for PostgreSQL. The critical aspect is how you define your database connectivity in config/database.yml. Perhaps helpful, check out brilliant Ryan Bates' RailsCast:

[Rails] Re: How to generate Rails models from database schemas

2015-05-22 Thread kenatsun
I know how to *connect *a Rails app to a PG database. My question is about how to align the Rails *contents *(model definitions) with the database contents (table definitions), so that the app can read from and write to the tables. It think perhaps you're answering yes to my question 2 -