Jason Hsu, Android developer
2013-Apr-19 23:15 UTC
How do I work with an EXISTING database?
I have a standalone Ruby script that downloads web pages, scrapes data from these downloaded pages, and stores the results in a Postgres database. This script is to run nightly. (My project is called Bargain Stock Funds. This database stores data on mutual funds and ETFs.) I am working on a Rails web site that needs to read data from this Postgres database and display information on selected mutual funds and/or ETFs.. How do I work with a database that already exists? The tutorials and examples out there seem to focus on creating a database rather than working with a pre-existing one. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/uncHTL9GMMMJ. For more options, visit https://groups.google.com/groups/opt_out.
On Apr 19, 2013, at 5:15 PM, Jason Hsu, Android developer wrote:> I have a standalone Ruby script that downloads web pages, scrapes data from these downloaded pages, and stores the results in a Postgres database. This script is to run nightly. (My project is called Bargain Stock Funds. This database stores data on mutual funds and ETFs.) > > I am working on a Rails web site that needs to read data from this Postgres database and display information on selected mutual funds and/or ETFs.. > > How do I work with a database that already exists? The tutorials and examples out there seem to focus on creating a database rather than working with a pre-existing one.If your database is structured the way rails wants it, there''s nothing more to do than define a model for each table. If your table names are not named the way Rails would name them, there''s a method you use in the model class to specify the name. If you primary key field is not named id, there''s a method... And so on for many other things. If you do not have an integer primary key, then things get difficult. But if you have integer primary keys on each table, then really you just need to be looking at the model class docs to figure out how to handle your tables. -- Scott Ribe scott_ribe-ZCQMRMivIIdUL8GK/JU1Wg@public.gmane.org http://www.elevated-dev.com/ (303) 722-0567 voice -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.