I have a database in Interbase and I want to access it directly from my Rails app using ActiveRecord. How can I do it?
There is a gem called activerecord-interbase-adapter although I haven't used it.
Related
I'm using pgcrypto gem to encrypt data in certain columns of the database, but in order for this gem to work I have to specify pgcrypto as an adapter in database.yml file. I know that Heroku disregards this file and generates its own when application is pushed to Heroku server, which uses default postgresql adapter. Does anybody know if it's possible to override adapter value, with a configuration variable for example?
Eventually found the solution, which happened to be a quite simple one - I just had to replace the first token in the Heroku's database URL variable, so instead of
postgres://username:password#host:port/dbname
I use
pgcrypto://username:password#host:port/dbname
You can manually create a database connection with
`ActiveRecord::Base.establish_connection(config)
you could also do this on a per-model basis using a mixing.
More info is here Understanding how establish_connection works in ActiveRecord
So basically I am making a new sample application that will run using an external Postgres database and a model, both created by another programmer who has given me this project.
I am supposed to create a rails app that will implement the model and database in order to add some mapping functionality. The problem is that I truly do not know how to migrate an existing database using the "db_name.sqldump" file they provided me. I have installed psql, created a new rails app and added the "pg" gem, but I haven't been able to create a table with all the model information.
I am not sure if I am being clear but I truly am pretty much lost here with RoR. Any input would help.
Assuming you've a pg_dump file, import it from the command line using either of psql or pg_restore.
http://www.postgresql.org/docs/current/interactive/app-pgrestore.html
Follow this railscast by Ryan Bates - http://railscasts.com/episodes/342-migrating-to-postgresql
To convert your sqldump to a sqlite db, Follow these guides : -
script to convert mysql dump sql file into format that can be imported into sqlite3 db
http://code-n-fold.com/2011/11/28/convert-mysql-dump-to-sqlite-format/
I like that Ruby On Rails allows you to write a simple schema in which you can create and update a database using. Is there any tool like Ruby On Rails's migration, as I would like to use the method without using Ruby On Rails for my website development?
There's no reason you can't use ActiveRecord::Migration outside of a rails app. In fact, you'll find plenty of examples of people doing this, as in http://exposinggotchas.blogspot.com/2011/02/activerecord-migrations-without-rails.html
If you're using mongo as the persistent store, check out mongrations for this.
I have heard this week on a little conference a talk about a tool called Liquibase, a database change management tool. It is based on Java (I think), but manages the database migrations in an XML file. The change sets you have to write are similar to the migrations you can write with Rails. If you use Liquibase inside an IDE like Eclipse, you get completion for all relevant parts of the change sets. It supports a lot of databases out of the box, so it could be an alternative, especially that nowadays Java is installed everywhere.
I recommend Python Alembic. It's not Ruby though.
There's a Rails 3.2.3 web application which doesn't use any database. But in spite of that if I use the gem 'sqllite3' in GemFile I works perfect. But if I use gem 'pg' in that file it throws an error
ActiveRecord::ConnectionNotEstablished
Of course, I use different versions of database.yml when I use postgreSql or SqlLite3.
But I definitely don't use any database.
Why is it happening? What should I do to solve it? And how to disable using databases?
See the SO question here for how to bypass using a database. It's a little more work than just setting a flag.
I created a view and was able to successfully access it through rails by creating the view through a migration with execute sql.
The problem with this is that the view is not entered into the schema. So when I need to create my test database to run my tests against the view is not created. I then need to create it by running the sql statement. Is there a way to implement SQL views elegantly in ruby on rails?
My environment:
Ruby on Rails 3.0.3
PostgreSQL 8.3
The rails_sql_views gem is intended to solve this problem. It adds support to the schema dumper to include views, which means you can use them in your test database. I'm not sure how well it works in Rails 3, but the github issues list has a pull request that appears to add Rails 3 support.
Possibly. using config.active_record.schema_format = :sql may help.