我该如何改进这种方法

时间:2016-05-25 08:25:13

标签: ruby-on-rails

有没有更好的方法来做到这一点。我正在寻找解决这个问题的替代方法

<library id="DB2JCC2Lib">
    <fileset dir="C:\Program Files\IBM\SQLLIB\java"/><!--includes="db2jcc.jar db2jcc_license_cu.jar db2jcc_license_cisuz.jar"-->
</library>

<dataSource id="xxdb" jndiName="jdbc/xxxx" type="javax.sql.ConnectionPoolDataSource">
    <jdbcDriver libraryRef="DB2JCC2Lib" id="db2-driver" javax.sql.ConnectionPoolDataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"/>

    <properties.db2.jcc driverType="2" databaseName="xxxx" portNumber="50000" user="xxxx" password="{aes}xxxx"/>
</dataSource>

1 个答案:

答案 0 :(得分:1)

您可以使用rails presence验证器作为开始和结束日期。

    <!DOCTYPE html>
    <html>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <body>

    <div ng-app="myApp" ng-controller="myCtrl">

    <p>Select a car:</p>

    <span ng-repeat="x in cars">
    <input type='checkbox' ng-model='x.checked'/>{{x.color}}
    </span>

    <h1>You selected: {{checkedModels()}}</h1>
    <p>Its color is: {{checkedColors()}}</p>

    </div>

    <script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope , $filter) {
        $scope.cars = [
            {model : "Ford Mustang", color : "red"},
            {model : "Fiat 500", color : "white"},
            {model : "Volvo XC90", color : "black"}
        ];

        $scope.checkedColors = function(){
       var checkedArr = $filter('filter')($scope.cars, {checked : true});
       var text = '';
       for(var i = 0 ; i < checkedArr.length ; i++) {
if(text.length != 0){text += ','}
text += checkedArr[i].color;
}
return text;
}

$scope.checkedModels = function(){
       var checkedArr = $filter('filter')($scope.cars, {checked : true});
       var text = '';
       for(var i = 0 ; i < checkedArr.length ; i++) {
if(text.length != 0){text += ','}
text += checkedArr[i].model;
}
return text;
}


    });
    </script>


    </body>
    </html>

然后我会使用你自己的验证方法来检查开始日期是否在结束日期之前。

validates :ld_work_start_date, presence: true
validates :off_work_date, presence: true