<div dir="ltr">This was many years ago, so I don't remember the details, but ActiveWarehouse had a gem/project for dealing with Views. It allowed you to create views in migrations - don't know what it did about schema.rb. This may/may not be rails 3/4 compatible.<div>
<br></div><div style>R</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 17, 2014 at 11:32 AM, Olly Legg <span dir="ltr"><<a href="mailto:ollylegg@gmail.com" target="_blank">ollylegg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I haven't used database views before, but I *think* you should switch to using a SQL schema, using `config.active_record.schema_format` (<a href="http://guides.rubyonrails.org/configuring.html#configuring-active-record" target="_blank">http://guides.rubyonrails.org/configuring.html#configuring-active-record</a>) and you can then use ActiveRecord::Connection#execute to create & manage your views (<a href="http://guides.rubyonrails.org/migrations.html#when-helpers-aren-t-enough" target="_blank">http://guides.rubyonrails.org/migrations.html#when-helpers-aren-t-enough</a>).<div>
<br></div><div>It should Just Work™.</div><div><br><div><div><div class="h5"><div>On 17 Jan 2014, at 11:20, Ed James (Alt) <<a href="mailto:ed.james.spam@gmail.com" target="_blank">ed.james.spam@gmail.com</a>> wrote:</div>
<br></div></div><blockquote type="cite"><div><div class="h5">
                <div>
                    Hi all
                </div><div><br></div><div>Is anyone using db views in a Rails app? If so, maybe you can help. </div><div><br></div><div>My issue lies more around the management of the views, rather than using them in the app. I’ve done this before in a previous project but I don’t have access to that codebase anymore and I can’t remember what the hell I did.</div>
<div><ul><li>How do you make ActiveRecord recognise the view and exclude it from the schema.rb file?</li><li>I seem to remember keeping the views as .sql files which were executed after a migration (by enhancing the db:migrate task). Any variations on this?</li>
</ul><div>The only gem I’ve managed to find is this one: <a href="https://github.com/railsware/db_structure_ext/tree/master/lib/db_structure_ext" target="_blank">https://github.com/railsware/db_structure_ext/tree/master/lib/db_structure_ext</a></div>
<div>Seems very old though and this seems like something which doesn’t need a gem. I know we didn’t use one previously.</div><div><br></div><div>Unfortunately using the word “view” in search criteria is not very useful ;)</div>
<div><br></div><div>Thanks,</div></div><div>Ed.</div></div></div>
            _______________________________________________<br>Chat mailing list<br><a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br><a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote></div><br></div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br></div>