2010-05-30 4 views
0

J'ai un contrôleur appelé 'Exposures' que j'ai créé automatiquement avec le script/générer un appel d'échafaudage. Les pages d'échafaudage fonctionnent bien. J'ai créé une action personnalisée appelée 'test' dans le contrôleur d'expositions. Lorsque j'essaie d'appeler la page (http://127.0.0.1:3000/exposures/test/1), j'obtiens un écran blanc et vierge, sans aucun texte dans la source. J'utilise Rails 2.3.8 et mongrel dans l'environnement de développement. Il n'y a pas d'entrées dans development.log et la console qui a été utilisé pour ouvrir bâtarde a l'erreur suivante:Problème de routage des rails personnalisés avec 2.3.8 et Mongrel

You might have expected an instance of Array. The error occurred while evaluating nil.split> D:/Rails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/cgi_process.rb:52:in dispatch_cgi' D:/Rails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:101:in dispatch_cgi' D:/Rails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:27:in dispatch' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/rails.rb:76:in process' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/rails.rb:74:in synchronize' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/rails.rb:74:in process' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:159:in process_client' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:158:in each' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:158:in process_client' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:285:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:285:in initialize' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:285:in new' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:285:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:268:in initialize' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:268:in new' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel.rb:268:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/configurator.rb:282:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/configurator.rb:281:in each' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/configurator.rb:281:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:128:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/../lib/mongrel/command.rb:212:in run' D:/Rails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:281 D:/Rails/ruby/bin/mongrel_rails:19:in load' D:/Rails/ruby/bin/mongrel_rails:19

Voici le code exposures_controller:

class ExposuresController < ApplicationController 
    # GET /exposures 
    # GET /exposures.xml 
    def index 
    @exposures = Exposure.all 

    respond_to do |format| 
     format.html # index.html.erb 
     format.xml { render :xml => @exposures } 
    end 
    end 

    #/exposure/graph/1 
    def graph 
    @exposure = Exposure.find(params[:id]) 
    project_name = @exposure.tender.project.name 
    group_name = @exposure.tender.user.group.name 
    tender_desc = @exposure.tender.description 
    direction = "Cash Out" 
    direction = "Cash In" if @exposure.supply 
    currency_1_and_2 = "#{@exposure.currency_in} => #{@exposure.currency_out}" 
    title = "#{project_name}:#{group_name}:#{tender_desc}/n" 
    title += "#{direction}:#{currency_1_and_2}" 
    factors = Array.new 
    carrieds = Array.new 
    days = Array.new 
    @exposure.rates.each do |r| 
    factors << r.factor 
    carrieds << r.carried 
    days << r.day.to_s  
    end 
    max = (factors+carrieds).max 
    min = (factors+carrieds).min 

    g = Graph.new 
    g.title(title, '{font-size: 12px;}') 
    g.set_data(factors) 
    g.line_hollow(2, 4, '0x80a033', 'Bounces', 10) 
    g.set_x_labels(days) 
    g.set_x_label_style(10, '#CC3399', 2); 
    g.set_y_min(min*0.9) 
    g.set_y_max(max*1.1) 
    g.set_y_label_steps(5) 
    render :text => g.render 
    end 

    def test 
    render :text => "this works" 
    end 



    # GET /exposures/1 
    # GET /exposures/1.xml 
    def show 
    @exposure = Exposure.find(params[:id]) 
    @graph = open_flash_chart_object(700,250, "/exposures/graph/#{@exposure.id}") 
    #@graph = "/exposures/graph/#{@exposure.id}" 


    respond_to do |format| 
     format.html # show.html.erb 
     format.xml { render :xml => @exposure } 
    end 
    end 

    # GET /exposures/new 
    # GET /exposures/new.xml 
    def new 
    @exposure = Exposure.new 

    respond_to do |format| 
     format.html # new.html.erb 
     format.xml { render :xml => @exposure } 
    end 
    end 

    # GET /exposures/1/edit 
    def edit 
    @exposure = Exposure.find(params[:id]) 
    end 

    # POST /exposures 
    # POST /exposures.xml 
    def create 
    @exposure = Exposure.new(params[:exposure]) 

    respond_to do |format| 
     if @exposure.save 
     flash[:notice] = 'Exposure was successfully created.' 
     format.html { redirect_to(@exposure) } 
     format.xml { render :xml => @exposure, :status => :created, :location => exposure } 
     else 
     format.html { render :action => "new" } 
     format.xml { render :xml => @exposure.errors, :status => unprocessable_entity} 
     end 
    end 
    end 

    # PUT /exposures/1 
    # PUT /exposures/1.xml 
    def update 
    @exposure = Exposure.find(params[:id]) 

    respond_to do |format| 
     if @exposure.update_attributes(params[:exposure]) 
     flash[:notice] = 'Exposure was successfully updated.' 
     format.html { redirect_to(@exposure) } 
     format.xml { head :ok } 
     else 
     format.html { render :action => "edit" } 
     format.xml { render :xml => @exposure.errors, :status => unprocessable_entity} 
     end 
    end 
    end 

    # DELETE /exposures/1 
    # DELETE /exposures/1.xml 
    def destroy 
    @exposure = Exposure.find(params[:id]) 
    @exposure.destroy 

    respond_to do |format| 
     format.html { redirect_to(exposures_url) } 
     format.xml { head :ok } 
    end 
    end 
end 

lecteurs Clever remarqueront le « graphique » action. C'est ce que je veux vraiment travailler, mais si je n'arrive même pas à faire fonctionner le test, alors je suis sûr que je n'ai aucune chance.

Des idées? J'ai redémarré le bâtard quelques fois sans changement.

Voici la sortie de Rake routes (mais je ne crois pas que ce soit le problème.L'erreur serait sous la forme de et la réponse d'erreur HTML).

D:\Rails\rails_apps\fx>rake routes 
(in D:/Rails/rails_apps/fx) 
DEPRECATION WARNING: Rake tasks in vendor/plugins/open_flash_chart/tasks are deprecated. Use lib/tasks instead. (called from D:/ 
by/gems/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:10) 
     rates GET /rates(.:format)     {:controller=>"rates", :action=>"index"} 
       POST /rates(.:format)     {:controller=>"rates", :action=>"create"} 
    new_rate GET /rates/new(.:format)    {:controller=>"rates", :action=>"new"} 
    edit_rate GET /rates/:id/edit(.:format)   {:controller=>"rates", :action=>"edit"} 
     rate GET /rates/:id(.:format)    {:controller=>"rates", :action=>"show"} 
       PUT /rates/:id(.:format)    {:controller=>"rates", :action=>"update"} 
       DELETE /rates/:id(.:format)    {:controller=>"rates", :action=>"destroy"} 
     tenders GET /tenders(.:format)     {:controller=>"tenders", :action=>"index"} 
       POST /tenders(.:format)     {:controller=>"tenders", :action=>"create"} 
    new_tender GET /tenders/new(.:format)    {:controller=>"tenders", :action=>"new"} 
    edit_tender GET /tenders/:id/edit(.:format)  {:controller=>"tenders", :action=>"edit"} 
     tender GET /tenders/:id(.:format)    {:controller=>"tenders", :action=>"show"} 
       PUT /tenders/:id(.:format)    {:controller=>"tenders", :action=>"update"} 
       DELETE /tenders/:id(.:format)    {:controller=>"tenders", :action=>"destroy"} 
    exposures GET /exposures(.:format)    {:controller=>"exposures", :action=>"index"} 
       POST /exposures(.:format)    {:controller=>"exposures", :action=>"create"} 
new_exposure GET /exposures/new(.:format)   {:controller=>"exposures", :action=>"new"} 
edit_exposure GET /exposures/:id/edit(.:format)  {:controller=>"exposures", :action=>"edit"} 
    exposure GET /exposures/:id(.:format)   {:controller=>"exposures", :action=>"show"} 
       PUT /exposures/:id(.:format)   {:controller=>"exposures", :action=>"update"} 
       DELETE /exposures/:id(.:format)   {:controller=>"exposures", :action=>"destroy"} 
    currencies GET /currencies(.:format)    {:controller=>"currencies", :action=>"index"} 
       POST /currencies(.:format)    {:controller=>"currencies", :action=>"create"} 
new_currency GET /currencies/new(.:format)   {:controller=>"currencies", :action=>"new"} 
edit_currency GET /currencies/:id/edit(.:format)  {:controller=>"currencies", :action=>"edit"} 
    currency GET /currencies/:id(.:format)   {:controller=>"currencies", :action=>"show"} 
       PUT /currencies/:id(.:format)   {:controller=>"currencies", :action=>"update"} 
       DELETE /currencies/:id(.:format)   {:controller=>"currencies", :action=>"destroy"} 
    projects GET /projects(.:format)    {:controller=>"projects", :action=>"index"} 
       POST /projects(.:format)    {:controller=>"projects", :action=>"create"} 
    new_project GET /projects/new(.:format)   {:controller=>"projects", :action=>"new"} 
edit_project GET /projects/:id/edit(.:format)  {:controller=>"projects", :action=>"edit"} 
     project GET /projects/:id(.:format)   {:controller=>"projects", :action=>"show"} 
       PUT /projects/:id(.:format)   {:controller=>"projects", :action=>"update"} 
       DELETE /projects/:id(.:format)   {:controller=>"projects", :action=>"destroy"} 
     groups GET /groups(.:format)     {:controller=>"groups", :action=>"index"} 
       POST /groups(.:format)     {:controller=>"groups", :action=>"create"} 
    new_group GET /groups/new(.:format)    {:controller=>"groups", :action=>"new"} 
    edit_group GET /groups/:id/edit(.:format)   {:controller=>"groups", :action=>"edit"} 
     group GET /groups/:id(.:format)    {:controller=>"groups", :action=>"show"} 
       PUT /groups/:id(.:format)    {:controller=>"groups", :action=>"update"} 
       DELETE /groups/:id(.:format)    {:controller=>"groups", :action=>"destroy"} 
     users GET /users(.:format)     {:controller=>"users", :action=>"index"} 
       POST /users(.:format)     {:controller=>"users", :action=>"create"} 
    new_user GET /users/new(.:format)    {:controller=>"users", :action=>"new"} 
    edit_user GET /users/:id/edit(.:format)   {:controller=>"users", :action=>"edit"} 
     user GET /users/:id(.:format)    {:controller=>"users", :action=>"show"} 
       PUT /users/:id(.:format)    {:controller=>"users", :action=>"update"} 
       DELETE /users/:id(.:format)    {:controller=>"users", :action=>"destroy"} 
        /:controller/:action/:id 
        /:controller/:action/:id(.:format) 

Merci à l'avance pour l'aide

-Jon

Répondre

Questions connexes