Ruby on Rails Friday, August 29, 2014

Sebastian wrote in post #599469:
> Hi,
>
> first of all I will apologize in advance for my presumably noobish
> question, but I'm only starting to learn Rails and am a little
> confused with all the changes in 2.0.1. There are as good as no
> tutorials out yet and the 2 or 3 screencasts I've seen deal with the
> creation of both the app and the database.
>
> Now my problem is that I already have a database with a fair amount of
> records in it (contacts with columns id:integer, first_name:string,
> last_name:string). In order to get a simple CRUD interface (that's all
> I want for now), with the pre-2.0 version of Rails, I could simply
> "generate scaffold contacts" and the framework would provide me with
> all the necessary files to get started with (controller, model and
> views).
>
> When I try the same command ("generate scaffold contacts") in 2.0.1 it
> will almost do the same thing, but somehow it misses all the fields
> from the database. The list-view solely contains a long listing of
> "Show Edit Destroy" lines (no first or last name listed here). When I
> click on Edit, the form just provides me with an update button. So no
> fields for first- and last name here either.
>
> Is it supposed to be this way now in 2.0.1? If so, what can I do to
> bring back the old functionality?
>
> Regards,
>
> Sebastian


Just another quick solution. You can generate the Ruby
scaffolding commands using SQL out of the database. Just access
sys.columns or whatever your particular database provides
(INFORMATION_SCHEMA or something). For each column, generate that line
that Ruby wants for a column / table entry. Then you can select as you
want for the Ruby app deleting unwanted column / table lines.

Does anyone have a definitive Ruby generation command for Nifty
using Ruby 4, for an existing database? I could generate the entire
thing via SQL, which I would be happy to provide.

--
Posted via http://www.ruby-forum.com/.

--
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/d7d75f2aab7fe38d3f0ba61b4129f49e%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment