ActiveRecord自定义“AS”标识符

时间:2016-09-13 00:13:28

标签: ruby-on-rails oracle activerecord

一些rails代码如:

<div class="modal-dialog demo-modal">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×
            </button>
            <!-- CUSTOM LOGIC HERE (This is to set it as Bug Edit or New Bug)-->
            <h4 class="modal-title">Bug Edit || New Bug</h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <!-- CUSTOM LOGIC HERE (This is to set prefilled text or placeholder text)-->
                        <textarea class="form-control" id="bug" rows="5" required>Specific Bug Error</textarea>
                    </div>
                </div>
            </div>           
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary">
                Save Changes
            </button>
        </div>
    </div><!-- /.modal-content -->
</div>

将执行sql:

@result = Table_One.join(Table_Two, Table_Three).
where(id = '1').
group(:val1, :val2, :amount).
sum(:amount)

只是想知道是否有办法自定义“as”规则,所以我可以得到一些像

这样的SQL
SELECT SUM(Table_One.amount) as table_one_amount, Table_One.val1 as table_one_val1 ....

0 个答案:

没有答案