I am new bee to Rais. I need to create a Rails application with existing database with several number of tables. When i came across web, I didn’t find any fruitful ideas for developing application using existing tables. Everything i found was to create new database with Create, Edit, Insert feature. I need to create a application using existing postgresql database stuffed with tables where i have to provide view only permission to the user. Kinldy help me in this regard. I have 15 tables in my database which developed in postgresql. Advance thanx to my friends of RoR-Talk.
Start with googling 'rails legacy database' for ideas.
Providing only 'read access' simply means your rails application should
not accept any new/create/update requests, and there are numerous ways
to defend against this.
"its not working" isn't particularly useful information.
So you have an existing table, say "things". You create a model for
it, e.g.
class Thing < ActiveRecord::Base
end
Done. Maybe you have to tell it there's a non-Rails-standard index
field, etc., but basically that's it. There's no reason to be fooling with
migrations if you have an existing table, unless you can and want to
do transformations on them to make them more Rails-like.
So what have you tried, and what's the actual problem?
I feel that, this is same kind of results I got in google search… Creating
model using dumped schemas of existing table. but, its not working.
“its not working” isn’t particularly useful information.
So you have an existing table, say “things”. You create a model for
it, e.g.
class Thing < ActiveRecord::Base
end
Done. Maybe you have to tell it there’s a non-Rails-standard index
field, etc., but basically that’s it. There’s no reason to be fooling with
migrations if you have an existing table, unless you can and want to
do transformations on them to make them more Rails-like.
Realy Sorry… If my problem was not understandable. I am a new bee… there is no perfect tutorials available for already existing tables to develop web interface. In before cases I used cgi and perl. Now I started ruby and RoR. I feel its totally different from cgi. If you know any turorials with examples, kindly tell me. In previously mentioned link, I am unable to understand.
The earlier link was irrelevant, ignore it. The advice to google "rails
legacy database" from Ar Chron should help, though.
In any case, make a copy of your existing DB and point your Rails
app at it.
Create a model based on an existing table e.g. "things", as in
class Thing < ActiveRecord::Base
end
Then start a console and type
thing = Thing.first
Look at the result. That should get you started
And no, sorry, I don't know of any specific tutorials on doing this. It
would probably be easier if you'd already developed at least a trivial
green-field Rails app (gone through the basic tutorials, guides, etc.)
Absolutely, and odds are the OP will encounter other grief in the form
of naming conventions/pluralization yadda yadda.
But creating a model and seeing what happens and where it breaks[*]
is the best way to start, IMO. And as a matter of fact I'm currently up
to my armpits in a similar project, though I do have the leeway to do
a few Railsizations to the db schema, thankfully.