Ruby on Rails Friday, February 14, 2014



On Friday, February 14, 2014 10:28:44 AM UTC, Juan Andres Rodriguez wrote:
I have generated a model and a controller in rails 4,Client and ClientsController, and configure the database.yml with the postgres adapater and the database name, and i want that rails get the table attributes from the clients table and generate the forms and all the scaffolding CRUD operations. I've seen in the web some similar solutions but with mysql database and i think with rails 3:

class ClientsController < ApplicationController    scaffold:client  end

but when calling any of the web urls, rails advertised that i have pending migrations, and if you think about it i dont need to migrate the model because is already in the database....


Rails doesn't really do scaffolding for existing models: the views etc. are generated statically rather than by introspecting the current state of the model (This was removed from rails around the rails 2 time - I think it was extracted into a plugin and there are other gems that produce an admin type interface automatically from the schema (eg activeadmin, activescaffold).

You could i suppose generate the scaffold and then delete all the database migrations, leaving only the controllers/views. When you generate the scaffold you would have to list all the attributes you want the scaffold to be aware of.

Lastly, none of this should depend on which db you are using

Fred
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c672df40-a769-44cf-8baa-505d0d4a22d9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment