문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top