I understand that seed.rb is used to seed the database with data for the application in production.
I want to create some data for use with tests and also for development.
Where should I put the code to create this data?
Thanks
Rails 3.2
Related
Currently we have a single Aurora Postgresql db instance that we are interacting with but I would like to add one more db instance so that we can read from one database and write to another(existing one). We are using Hanami v1.3 and the project is in ruby.
I am trying to find documentation/resources on how to implement this and is it possible to do so?
This is not possible in Hanami v1.3, checkout the following link:
https://github.com/hanami/hanami/issues/1028
In hanami 2 (already in beta 🥳) it is possible through rom-rb (you will love to work with it). I would not recommend to start a new project with hanami 1.3. I would go definitely with 2.0.
Is it possible to get the Active Record migration generators that Rails has to work in a project that is not using Rails -- perhaps via rake tasks.
I have a Ruby project that is using ActiveRecord but it is not a Rails project. So far, I create my migrations by hand which works but it would be nice to get the migration generators to work. Is that practical?
I wrote several Rails 3 integration tests using Watir-Webdriver (0.9.1) that test whether a user can register. These tests run fine and pass. However, I've been running these tests with a rails server running so that Watir can access my site and work its way through the webpages. This presents a problem because that means I am running my tests on the development environment, and because of that I can't get accurate numbers for lines covered by my tests and all the information I input through Watir goes into a different database that my tests do not have access to.
If I try to run my rails server in the test environment, it gives me an error (SQLite3 ReadOnlyException) when I try to register a user. I've been led to believe that this is because SQLite3 does not want to be used by both the test server and my test code at the same time. I do not think it is actually a Read Only database because I have used chmod 777 on it and its folders with no success.
Is there a way to make it so that my integration tests do not actually need a rails server up in order to access my site? Or do I just need to use the development environment for my server and test to make sure the right data is being submitted somewhere else (i.e. a different type of test)?
I searching for an way to do a different migration in production and development.
I want to create a Spring Webapplication with Maven.
In development i want to update database schema AND load test data.
In production when a new version of the application is deployed i want only change the schema and don't load test data.
My first idea was to save the schema update and insert statements into different folders.
I think every body has solved this problem and can help me, thank you very much.
Basically, you have two options:
You could use different locations for your migrations in your flyway.locations property, i.e.:
for Test
flyway.locations=sql/structure,sql/test
for Production
flyway.locations=sql/structure
That way, you include your test data in the sql/test folder. You would have to take care with numbering, of course.
The second option (the one I prefer), is don't include test data in your migrations at all.
Rather, create your testdata any way you want and create an sql-dump of this data, which you keep separate from your migrations.
This works best if you have a separate database (instance, schema, whatever) containing your pristine testdata, where you apply each migration as part of your build process. This build job could then create a dump always matching the current migration.
When preparing your test machine, you first apply your migrations, then you load the contents of the matching dump.
I think this is a lot cleaner than the first version, especially because your test data can be prepared using other tools (your application) and has not to be handcoded.
my Ruby on rails application not support Active record rails app used active resource API for featch data from another server , how i deploy the rails application to Heroku with no migration , schema , database file app,
You could easily do that without any migrations although heroku will assign you a default database which you will never use. It will not create any problem IMO. Go ahead and give it a try.