Question

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

Was it helpful?

Solution

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.

OTHER TIPS

Possibly. using config.active_record.schema_format = :sql may help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top