doupao1530 2013-02-01 15:25
浏览 83

在rails注册模块上的ruby中没有路由匹配

I developed a php application which contains the registration module ( this application is recorded under www file )

this application uses a appilication which is developed with ruby on rails

but when I test this application ( I talk about php application)

I have this error in the consol of ruby on rails

 Parameters: {"_"=>"1359731468907", "mobile"=>"22222222", "idcard"=>"01256321", "callback"=>"jQuery17103156804504705649_1359731205632"}


ActionController::RoutingError (No route matches "/cui/public/inscription/m.php" with {:method=>:get}):
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:67:in `recognize_path'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:384:in `recognize'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:148:in `handle_request'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load'
    /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/mongrel.rb:64
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
    /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3

Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/templates/rescues/layout.erb (not_found)

in router.rb which is under config I have this code :

 ActionController::Routing::Routes.draw do |map|
      # The priority is based upon order of creation: first created -> highest priority.

      # Sample of regular route:
      #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
      # Keep in mind you can assign values other than :controller and :action

      # Sample of named route:
      #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
      # This route can be invoked with purchase_url(:id => product.id)

      # Sample resource route (maps HTTP verbs to controller actions automatically):
      #   map.resources :products

      # Sample resource route with options:
      #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

      # Sample resource route with sub-resources:
      #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

      # Sample resource route within a namespace:
      #   map.namespace :admin do |admin|
      #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
      #     admin.resources :products
      #   end

      # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
      map.root :controller => "login"

      # See how all your routes lay out with "rake routes"
      map.connect '/send', :controller => 'transaction', :action => 'send_transaction'
      map.connect '/admin/users/:action', :controller => 'admin_users'
      map.connect '/admin/users/:action/:login/', :controller => 'admin_users'
      map.connect '/admin_admins/:action/:role/', :controller => 'admin_admins'
      map.connect '/admin_accounts/:action/:login/:account_id', :controller => 'admin_accounts'
      map.connect '/admin_admins/:action/', :controller => 'admin_admins'
      map.connect '/add_admin', :controller => 'admin_admins', :action => 'add_confirm'
      map.connect '/archidoc/:date', :controller => 'archidoc'
      map.connect '/reporting/:date', :controller => 'reporting'
      map.connect '/approve_pay', :controller => 'approve_pay'

      # Activating email address.
      map.connect '/activation/:code', :controller => 'user', :action => 'activation'
      map.connect '/activate/:activation_code', :controller => 'admin', :action => 'activate'
      # Resend confirmation.
      map.connect '/confirm_email', :controller => 'user', :action => 'confirm_email'

     #  map.connect '/link_account/:login', :controller => 'admin_users', :action => 'link_account'
     #  map.connect '/admin_admin_account/:login', :controller => 'admin_admin', :action => 'link_account'

      # Install the default routes as the lowest priority.
      map.connect ':controller/:action/:login'
      map.connect ':controller/:action/:login.:format'
      map.connect ':controller/:action/'

    #  map.connect '/setmeup/:login', :controller => 'login', :action => 'test_setup'
      # random requests to a null stylesheet clutter up the logs
      map.connect '/stylesheets/null', :controller => 'login', :action => 'null'
    end

maybe I should added another line in this file to render ruby able to answer to /cui/public/

As I said the php application is named public I make it under www of apache

and I also I make this application under the source code of ruby on rails

in the php application which is under www I have this files :

mdinar.js

var idtype;
var mobile;
var idtype ;
var mobile;
var idcard ;
var firstname; 
var lastname ;
var formid;
var email;
var gender;
var ip_access;
var step = 1;
var dom = "http://0.0.0.0:3000/cui/public/inscription";

jQuery(document).ready( function () {

    jQuery("ul#bottom-menu.menu li:last").css({"border":"0px"});

    jQuery("a[rel='grille']").click(function(){ jQuery("div.accordionButton[id='grille']").trigger('click'); });

    jQuery("#page_nav a:first").addClass("selected");

    jQuery('#page_slider').cycle({ 
        fx:     'scrollHorz', 
        speed:   300
    })

    jQuery('#page_slider').cycle('pause');
    jQuery("#page_nav a[rel]").click(function() {
        jQuery("#page_nav a[rel]").removeClass("selected");
        jQuery(this).toggleClass("selected");

        var arr = jQuery(this).attr('rel').split('cycle-') ;
        var i = arr[1];

        jQuery('#page_slider').cycle('resume');
        jQuery('#page_slider').cycle(parseInt(i));
        jQuery('#page_slider').cycle('pause');
    });



    jQuery("input:text[id='mobile']").keyup(function(e) {
        if ( jQuery(this).val().length > 8 )  {
            jQuery(this).val( jQuery(this).val().substr(0, 8) );
            return false;
        }
    });

    jQuery("input:text[id='cin']").keyup(function(e) {
        if ( jQuery(this).val().length > 10 )  {
            jQuery(this).val( jQuery(this).val().substr(0, 10) );
            return false;
        }
    });


    jQuery("input:text[id='mobile'],input:text[id='cin']").keydown(function(e) {
        key = parseInt(e.keyCode);

        // white tab
        if (key == 32 )
            return false;


        if ( key >= 48 ) if ( key <= 57 )
            return true;

        if ( key >= 96 ) if ( key <= 105 )
            return true;

        if ( key >= 13 ) if ( key <= 46 )
            return true;

        // delete 
        if (key == 8 )
            return true;

        // tab
        if (key == 9 )
            return true;




        return false;
    });


    if ( jQuery("#formSignup").length ) {
        jQuery("#formSignup").submit(function() {

            if ( !jQuery("input[id='cgu']").is(":checked") && ( jQuery('#bToStep1').length <= 0 ) ) {
                alert('Vous devez lire et approuver les Conditions Générales d\'Utilisation');
                return false;
            }

            if ( jQuery("#mobile").val() == "" ) {
                    alert('Le numéro de téléphone est obligatoire');
                    return false;
            }

            if ( jQuery("#idcard").val() == "" ) {
                    alert('Le numéro de la CIN/CS est obligatoire');
                    return false;
            }

            if ( jQuery("#lastname").val() == "" ) {
                    alert('Le nom est obligatoire');
                    return false;
            }

            if ( jQuery("#firstname").val() == "" ) {
                    alert('Le prénom est obligatoire');
                    return false;
            }


            if ( jQuery("#email").val() == "") {
                    alert('L\'email est obligatoire');
                    return false;
            }

            if ( (jQuery("#email").val() != "") && (jQuery("#email").val() != jQuery("#email2").val()) ) {
                    alert('Veuillez confirmer votre email');
                    return false;
            }

            if ( jQuery("#address").val() == "" ) {
                    alert('L\'adresse est obligatoire');
                    return false;
            }

            if ( jQuery("#city").val() == "" ) {
                    alert('La ville est obligatoire');
                    return false;
            }

            if ( jQuery("#zipcode").val() == "" ) {
                    alert('Le code postal est obligatoire');
                    return false;
            }


            /*if ( jQuery("input[id='bank_account:yes']").attr("checked") == "checked" ) {
                if ( jQuery("#bank").val() == "" ) {
                        alert('La banque est obligatoire');
                        return false;
                }

                if ( jQuery("#agency").val() == "" ) {
                        alert('L\'agence est obligatoire');
                        return false;
                }
            }*/

            return true;

        });


    }

    jQuery("a[rel='inscription']").click(function() {
        jQuery.colorbox({href:"#media_inscription", width:"960px", height:"370px", inline:true});
    });

    jQuery("a[rel='demande']").click(function() {
        jQuery.colorbox({href:"#media_demande", width:"960px", height:"370px", inline:true});
    });

    jQuery("a[rel='transfert']").click(function() {
        jQuery.colorbox({href:"#media_transfert", width:"960px", height:"370px", inline:true});
    });


    jQuery("a[rel='demo']").click(function() {
        jQuery.colorbox({href:"#media_demo", width:"960px", height:"370px", inline:true});
    });


    if ( jQuery("#media_inscription").length ) {
        var flashvars = {};
        var params = {"wmode":"transparent"};
        var attributes = {};

        swfobject.embedSWF(dom + "swf/mdinar_inscription_v1.swf", "media_inscription", "900", "300", "9.0.0","swf/expressInstall.swf", flashvars, params, attributes);

    }

    if ( jQuery("#media_demande").length ) {
        var flashvars = {};
        var params = {"wmode":"transparent"};
        var attributes = {};

        swfobject.embedSWF(dom + "swf/mdinar_demande_v1.swf", "media_demande", "900", "300", "9.0.0","swf/expressInstall.swf", flashvars, params, attributes);

    }

    if ( jQuery("#media_transfert").length ) {
        var flashvars = {};
        var params = {"wmode":"transparent"};
        var attributes = {};

        swfobject.embedSWF(dom + "swf/mdinar_transfert_v1.swf", "media_transfert", "900", "300", "9.0.0","swf/expressInstall.swf", flashvars, params, attributes);

    }

    if ( jQuery("#media_demo").length ) {
        var flashvars = {};
        var params = {"wmode":"transparent"};
        var attributes = {};

        swfobject.embedSWF(dom + "swf/mdinar_demo_v1.swf", "media_demo", "900", "300", "9.0.0","swf/expressInstall.swf", flashvars, params, attributes);

    }



    jQuery("input#bToStep3").click(function(){
        var b = jQuery("#mobile").val();
        var c = jQuery("#idcard").val();

        jQuery.colorbox({href:"#msgContent", width:"400px", height:"200px", inline:true, onClosed: function() {
            if (step == 2) {
                //jQuery("input#bToStep3").val("Terminer l'inscription");           
            }
        }});

        jQuery.post(dom + "/m.php?callback=?", {mobile:b,idcard:c}, function(data) {

            jQuery("#msgContent").html("<h1>" + data.message + "</h1>");

            if (data.status == "1") {
                if (data.go == "1") {
                    step = 2;

                    var t = jQuery("#idtype").val();
                    var f  =jQuery("#firstname").val(); 
                    var l = jQuery("#lastname").val();
                    var e = jQuery("#email").val();
                    var g = jQuery("#gender").val();

                    // added
                    var birthdate_d = jQuery("#birthdate_d").val();
                    var birthdate_m = jQuery("#birthdate_m").val();
                    var birthdate_y = jQuery("#birthdate_y").val();
                    var address = jQuery("#address").val();
                    var city = jQuery("#city").val();
                    var gouv = jQuery("#gouv").val();
                    var profession = jQuery("#profession").val();
                    var field = jQuery("#field").val();
                    var bank_account = jQuery("#bank_account").attr('checked');
                    var bank = jQuery("#bank").val();
                    var agency = jQuery("#agency").val();
                    var fb = jQuery("#fb").attr('checked');
                    var twitter = jQuery("#twitter").attr('checked');
                    var blog = jQuery("#blog").attr('checked');
                    var friends = jQuery("#friends").val();
                    var followers = jQuery("#followers").val();
                    var blog_url = jQuery("#blog_url").val();
                    var website = jQuery("#website").val();
                    var civil_status= jQuery("#civil_status").val();
                    var nickname= jQuery("#nickname").val();
                    var zipcode = jQuery("#zipcode").val();
                    var deliv_lieu = jQuery("#delivrance_lieu").val();
                    var deliv_d = jQuery("#delivrance_d").val();
                    var deliv_m = jQuery("#delivrance_m").val();
                    var deliv_y = jQuery("#delivrance_y").val();
                    var expir_d = jQuery("#expiration_d").val();
                    var expir_m = jQuery("#expiration_m").val();
                    var expir_y = jQuery("#expiration_y").val();


                    jQuery("#msgContent").html("<h1>Création de votre compte...</h1>" + jQuery("div#vlr").html() );

                    jQuery.post(dom + "/c.php?callback=?", {idtype:t,mobile:b,idcard:c,firstname:f,lastname:l,email:e,gender:g,deliv_lieu:deliv_lieu, deliv_d:deliv_d, deliv_m:deliv_m, deliv_y:deliv_y, expir_d:expir_d, expir_m:expir_m,expir_y:expir_y, birthdate_d:birthdate_d, birthdate_m:birthdate_m,birthdate_y:birthdate_y, address:address, city:city, gouv:gouv, profession:profession, field:field, bank_account:bank_account, bank:bank, agency:agency, fb:fb, friends:friends, twitter:twitter, followers:followers, blog:blog, blog_url:blog_url, website:website, civil_status:civil_status, nickname:nickname, zipcode:zipcode}, function(data2) {

                        //alert(data2);
                        step = 3;

                        jQuery("#msgContent").html("<h1>" + data2.message + "</h1>");
                        //jQuery.colorbox.resize({width:'400px',height:'300px'});

                        if (data2.status == "0") { 
                            /*
                            setTimeout(function (){ 
                                   jQuery.colorbox.close(); 
                                    //window.location.href = "http://www.xilionlabs.com/tmp/mdinar/inscription-terminee/";
                            }, 1000);
                            */
                        }
                        else if (data2.status == "1") {

                            setTimeout(function (){ 
                                   jQuery.colorbox.close(); 
                                    window.location.href = dom + "/signup-done.php?";
                            }, 5000);

                        }                       
                    }, "json");
                }
                else {

                }
            }
        }, "json");
    });


    jQuery("input#bToStep4").click(function(){
        var t = jQuery("#idtype").val();
        var b = jQuery("#mobile").val();
        var c = jQuery("#idcard").val();
        var f  =jQuery("#firstname").val(); 
        var l = jQuery("#lastname").val();
        var m = jQuery("#formid").val();
        var e = jQuery("#email").val();
        var g = jQuery("#gender").val();

        jQuery.colorbox({href:"#msgContent", width:"400px", height:"200px", inline:true});

        jQuery.post(dom + "c.php", {idtype:t,mobile:b,idcard:c,firstname:f,lastname:l,formid:m,email:e,gender:g}, function(data) {
            //alert(data);
            if (data.mdinar_mdinar_validate_cin.status == "error") {
                jQuery("#msgContent").html(data.register_online.reason);
            }
            else if (data.register_online.status == "ok") {
                jQuery("#msgContent").html("OK");
            }
        });
    });


    jQuery("#gouvernorats table[id='tunis']").show();
    jQuery("#gouvernorats h3").html("Tunis");

    jQuery("#mapgouv area[alt]").click(function(){
        jQuery(this).css({"background-color":"#ccffff"});
        jQuery("#gouvernorats h3").html(jQuery(this).attr("alt"));  
        jQuery("#gouvernorats table").hide();
        jQuery("#gouvernorats table[id='" + jQuery(this).attr("id") + "']").show();
    });


});

and I have also m.php :

<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $mobile = urlencode($_POST["mobile"]);
    $idcard = urlencode($_POST["idcard"]);

    $url = "0.0.0.0:3000/mdinar_validate_cin/validate_cin?" ;
    $url .= "mobile=" . $mobile . "&idcard=" . $idcard . "&callback=?";


    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    $data = curl_exec($ch); 
    curl_close($ch); 



    $data = json_decode($data, true);
    $result = array();
    //print_r($data);
    if ( $data["mdinar_mdinar_validate_cin"]["status"] == "error" ) {
        $result["status"] = 0;

        switch($data["mdinar_mdinar_validate_cin"]["reason"]) {
            case "must_be_tunisiana_num" :
                $result["message"] = "Le format du numéro de téléphone est incorrect";
                break;

            case "incorrect_phone_format":
                $result["message"] = "Le format du numéro de téléphone est incorrect";
                break;

            case "phone_format_digits_only":
                $result["message"] = "Lé numéro de téléphone doit être numérique";
                break;

            default:
                $result["message"] = "Erreur inattendue";
        }
    }
    else {
        if ( $data["mdinar_mdinar_validate_cin"]["status"] == "ok" ) {
            $result["status"] = 1;

            if ( $data["mdinar_mdinar_validate_cin"]["response"] == "true" ) {
                $result["message"] = "Compte valide";
                $result["go"] = 1;
            }
            elseif ( $data["mdinar_mdinar_validate_cin"]["response"] == "false" ) {
                $result["message"] = "Compte invalide";
                $result["go"] = 0;
            }   
        }
    }


    echo $_REQUEST["callback"] . "(" . json_encode($result) . ");" ;
    exit;
}
$result["status"] = 0;
$result["message"] = "Erreur inattendue #2";

echo $_REQUEST["callback"] . "(" . json_encode($result) . ");" ;
exit;

c.php

<?php
session_start();

$formid = date("YmdHis");

if (true || $_SERVER['REQUEST_METHOD'] == "POST") {

    $idtype = urlencode(str_replace("
", "", trim($_REQUEST["idtype"])));
    $mobile = urlencode(str_replace("
", "", trim($_REQUEST["mobile"])));
    $idcard = urlencode(str_replace("
", "", trim($_REQUEST["idcard"])));
    $firstname = urlencode(str_replace("
", "", trim($_REQUEST["firstname"]))); 
    $lastname = urlencode(str_replace("
", "", trim($_REQUEST["lastname"])));
    $email = urlencode(str_replace("
", "", trim($_REQUEST["email"])));
    $gender = urlencode(str_replace("
", "", trim($_REQUEST["gender"])));
    $alias = urlencode(str_replace("
", "", trim($_REQUEST["nickname"])));
    $dob_d = urlencode(str_replace("
", "", trim($_REQUEST["birthdate_d"])));
    $dob_m = urlencode(str_replace("
", "", trim($_REQUEST["birthdate_m"])));
    $dob_y = urlencode(str_replace("
", "", trim($_REQUEST["birthdate_y"])));
    $ip_access = urlencode(trim($_SERVER['REMOTE_ADDR']));


    $P = serialize( $_POST );

    $mymdinar = mysql_connect("localhost", "root", "root");
    if ($mymdinar) {
        mysql_select_db("mdinardb2", $mymdinar);
    }

    // insere toutes les donness provenant de $_POST
    $sql = " INSERT INTO `my_mdinar` SET
            `formid` = '" . $formid . "',
            `data` = '" . mysql_escape_string($P) . "',
            `creation_date` = '" . date("Y-m-d H:i:s"). "' "; 

    @mysql_query($sql, $mymdinar);
    $lastId = mysql_insert_id($mymdinar);


    // genere le numero du contrat et met a jour $lastId
    $newContractId = '';
    $sql = " SELECT * FROM `my_mdinar` WHERE `contractid` != '' ORDER BY `id` DESC LIMIT 1 "; 
    $res = mysql_query($sql, $mymdinar);
    $row = mysql_fetch_assoc($res);

    $lastContractId = $row['contractid'];
    $newContractId = generateCodeInscription($lastContractId);

    $sqlUp = " UPDATE `my_mdinar` SET `contractid` = \"" . $newContractId . "\" WHERE `id` = " . $lastId;   
    mysql_query($sqlUp, $mymdinar);

    $formid = $newContractId;



    mysql_close($mymdinar);



$url = "http://0.0.0.0:3000/register_online/create?idtype=" . $idtype . "&mobile=" . $mobile . "&idcard=" . $idcard . "&firstname=" . $firstname . "&lastname=" . $lastname . "&formid=" . $formid . "&email=" . $email . "&gender=" . $gender . "&ip_access=" . $ip_access . "&dob_year=" . $dob_y . "&dob_month=" . $dob_m . "&dob_day=" . $dob_d . "&alias=" . $alias;


 $ch = curl_init(); 
            curl_setopt($ch, CURLOPT_URL, $url); 
            curl_setopt($ch, CURLOPT_HEADER, false); 
            curl_setopt($ch, CURLOPT_NOBODY, false); // remove body 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
            $data = curl_exec($ch);  
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch); 


    if ( $httpCode == 500 ) {
        $result["status"] = 0;
        $result["go"] = 0;
        $result["message"] = "Une erreur s'est produite sur notre serveur contactez service client pour r&eacute;cuperer votre formulaire";
        echo $_REQUEST["callback"] . "(" . json_encode($result) . ");" ;
        exit;
    }


    //echo $url;
    //echo $data;
    $data = json_decode($data, true);
    $result = array();

    $result["status"] = -1;
    $result["go"] = -1;
    $result["message"] = "";


    //if (1){
    if ($data["register_online"]["status"] == "ok") {
        $result["status"] = 1;
        $result["go"] = 1;
        $result["message"] = "Votre compte a été créé avec succès! 
Votre numéro de contrat est le suivant : " . $formid ;

        $result["formid"] = $formid;
        $_SESSION["CONTRAT"] = $formid;
        $_SESSION['buffer'] = null;
        if ($email) {
            $_SESSION["MSGEMAIL"] = 1;
        }

        include 'pdf/p.php';

    }
    elseif ( $data["register_online"]["status"] == "error" ) {
        $result["status"] = 0;
        $result["go"] = 0;

        switch($data["register_online"]["reason"]) {
            case "must_be_tunisiana_num" :
                $result["message"] = "Le format du numéro de téléphone est incorrect";
                break;

            case "user_exists" :
                $result["message"] = "Utilisateur existant";
                break;

            case "incorrect_phone_format":
                $result["message"] = "Le format du numéro de téléphone est incorrect";
                break;

            case "phone_format_digits_only":
                $result["message"] = "Lé numéro de téléphone ne doit comporter que des chiffres";
                break;

            case "incorrect_idcard_format":
                $result["message"] = "Format de la carte d'identité incorrect";
                break;

            case "incorrect_idcard_format_for_RC";
                $result["message"] = "Format du RC incorrect";
                break;

            case "incorrect_idcard_format_for_CS":
                $result["message"] = "Format de la CS incorrect";
                break;

            case "email_exists" :
                $result["message"] = "Email existant";
                    break;

            default:
                $result["message"] = "Une erreur s'est produite sur notre serveur contactez service client pour r&eacute;cuperer votre formulaire";
        }
    }
    //echo json_encode($result); exit;
    echo $_REQUEST["callback"] . "(" . json_encode($result) . ");" ;
    exit;
}
$result["status"] = 0;
$result["go"] = 0;
$result["message"] = "Erreur inattendue #2";

echo $_REQUEST["callback"] . "(" . json_encode($result) . ");" ;



function generateCodeInscription($lastCode){

    $letters = range('N', 'Z');

    $letterCode = substr($lastCode, 0, 1);
    if (!in_array($letterCode, $letters))
        $letterCode = 'Z';

    $intCode = (int) substr($lastCode, 1, 6);
    if ($intCode == 99999){
        $intCode = 1;
        $keyLetter = array_search($letterCode, $letters);
        $letterCode = $letters[$keyLetter-1];
    }else {
        $intCode++;
    }

    $newIntCode = sprintf("%06d", $intCode);
    //echo "newIntCode = $newIntCode<br>";
    return $letterCode . $newIntCode;

}

exit;

the most important think is this line in mdinar.js

var dom = "http://0.0.0.0:3000/cui/public/inscription";

and this line in m.php

$url = "0.0.0.0:3000/mdinar_validate_cin/validate_cin?" ;

and in c.php

$url = "http://0.0.0.0:3000/register_online/create?idtype=" . $idtype . "&mobile=" . $mobile . "&idcard=" . $idcard . "&firstname=" . $firstname . "&lastname=" . $lastname . "&formid=" . $formid . "&email=" . $email . "&gender=" . $gender . "&ip_access=" . $ip_access . "&dob_year=" . $dob_y . "&dob_month=" . $dob_m . "&dob_day=" . $dob_d . "&alias=" . $alias;

and I add this line under routers.er

map.connect '/mdinar_validate_cin', :controller => 'mdinar_validate_cin', :action => 'validate_cin'
  map.connect '/register_online', :controller => 'register_online', :action => 'create'

but I didn't have a haml file under mdinar_validate_cin and register_online

as I said it was written in php so we should just know how can we call a php file under ruby on rails

  • 写回答

1条回答 默认 最新

  • doqs8936 2013-02-01 16:00
    关注

    Routing in Rails is made for Rails Controllers.

    What you probably want here is to redirect somewhere without using products_url-like methods. What you could also potentially do is to have your php application under the public folder of Rails. Make sure your server is set up correctly to handle requests for your php application.

    If your php application is called 'foo' and handles 'bar.php' and assuming your structure looks like /public/foo/bar.php, your request should be handled properly.

    Again, don't use routes.rb to do that.

    ** Update

    If you are linking from your php application to your Rails application and you get that error, it is simply because Rails doesn't answer to /cui/public/... Make sure you link to a valid url that Rails handles in its config/routes.rb

    ** Update 2

    Either have a route for it in routes.rb that routes to controller#action AND/OR change the url in the form/link to point to a more RESTful route that Rails can already handle.

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献