4

In my rails app, I need to use an existing MS SQL database. I have tried following this manual:

http://rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html

I do not know how to do models, scaffolds, etc because rails cannot simply use another db. I didn't want to run rake db:migrate for my tables in the MS SQL database. What else do I need to write in the model? If simple: use tables from the MS SQL server's database, but I also want to solve problem with migrations, etc.

4
  • Are you wanting to hook Rails up to an existing database, or a new one? Commented Nov 22, 2012 at 16:07
  • @Snips yes: to connect to existing mssql... Commented Nov 22, 2012 at 16:47
  • Have a look at this question: stackoverflow.com/questions/4597570/… Commented Nov 22, 2012 at 17:17
  • @mccannf it is not exactly what i need... becouse from this existing mssql db i need generate fields in view too, etc... Commented Nov 22, 2012 at 18:05

1 Answer 1

1

If you need to run your Rails up on top of the existing database and you want to make sure you can create all models that match existing tables, follow this guide:

As an alternative to ActiveRecord altogether, you might consider DataMapper as it claims to work better with "brownfield" (i.e. already established) databases.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, and then for each model you create, you can run rails generate scaffold_controller ModelName to auto create controllers and views.
but will then i need to write all relations in models? has many, belongs?
also i need to create all models?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.