laurent25

Problem With Server-Side Export

Recommended Posts

Hello,

 

I'm using RoR so I have posted my issue in the RoR forum but since i got no answers the last couple of days I'm trying my luck here.

 

Here is my original post:

 

I'm trying to put in place a server-side export my charts.

 

Here is what I did so far:

 

- Copied fc_exporter_controller.rb, fc_exporter_img_controller.rb , fc_exporter_pdf_controller.rb controllers in Controllers/Fusioncharts/

- Copied error_handler.rb , error_messages.rb , generator.rb , properties.rb , save_helper.rb in Lib/fusioncharts/exporter/

- Copied error.html.erb into the Views folder

 

I have set the following tag on my chart:

 

:exportEnabled=>1,

:exportAtClient => 0,

:exportHandler=>"Fusioncharts/fc_exporter/index",

:exportFormats=>"JPG",

:exportaction=>"save"

 

I have modified the @@SAVEPATH to "./public/export/" in the properties.rb file

I have installed the gem rmagick

 

Now when I try to export my chart, i got a "RoutingError (No route matches "/Fusioncharts/fc_exporter/index")" which seems there is no route for that action (By the way there is no mention of that in the Readme.txt)

So I added a route => match 'Fusioncharts/fc_exporter/index' => 'fc_exporter#index'

And then i got this error: "RoutingError (uninitialized constant FcExporterController)"

 

Any clue on what I'm doing wrong?

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Thank you very much for your appreciation.

 

Happy FusionCharting!biggrin.gif

Share this post


Link to post
Share on other sites

Hi,

 

Thank you very much for your appreciation.

 

Happy FusionCharting!biggrin.gif

 

I still can't make it works :(

 

The route I had setup was wrong, missed the folder fusioncharts

I got this now:

match 'fusioncharts/fc_exporter/index' => 'fusioncharts/fc_exporter#index'

 

But i got a new error

 

ActionController::RoutingError (uninitialized constant Fusioncharts::Exporter):

lib/fusioncharts/exporter/error_handler.rb:8:in `<top (required)>'

app/controllers/fusioncharts/fc_exporter_controller.rb:45:in `<class:FcExporterController>'

app/controllers/fusioncharts/fc_exporter_controller.rb:44:in `<top (required)>'

 

I feel like i miss another route. Any doc anywhere that explain which route I have to setup in RoR to make this works?

Share this post


Link to post
Share on other sites

From what I understood, the sample is working but you are unable to make it work in your application. Is that right?

 

Let me take a look at the routes and get back to you.

 

Yes the sample worked nicely except the multi export one but that for later

As for my application I'm keep getting ActionController::RoutingError (uninitialized constant xxxxxxxxxxx)

Share this post


Link to post
Share on other sites

Can you please try setting :exportHandler=>"/fusioncharts/fc_exporter/index" once and tell me if it is working?

 

I have tried with this route: match 'exportHandler' => "fusioncharts/fc_exporter/index"

 

RoR didn't like match :exportHandler=>"/fusioncharts/fc_exporter/index"

 

But i got the same thing

 

ActionController::RoutingError (uninitialized constant Fusioncharts::Exporter):

lib/fusioncharts/exporter/error_handler.rb:8:in `<top (required)>'

app/controllers/fusioncharts/fc_exporter_controller.rb:45:in `<class:FcExporterController>'

app/controllers/fusioncharts/fc_exporter_controller.rb:44:in `<top (required)>'

 

This is driving me crazy :(

Share this post


Link to post
Share on other sites

Just to confirm, did you take the controller and other export related files from the Rails 3 sample?

 

I have tried with files from the FusionCharts_Evaluation (My compagny have licences but all they gave me was the fusioncharts JS and the swf files since they are working in PhP)

And I have tried with the files from the sample.

Share this post


Link to post
Share on other sites

Would it be possible for you to send me a scaled-down version of your application?

 

Yeah I could try to do a sample of my app this afternoon.

 

Meanwhile i tried to do a simple case test with the render_chart helper. My app is in EXT JS so i don't use them.

 

I did the same thing as the sample, I put the helpers in the libs folder and included FusionChartsHelper in application_helper.rb

But of course me i get an error: ActionController::RoutingError (uninitialized constant ApplicationHelper::FusionChartsHelper)

 

I have a very simple action :

 

def test

#Number of terminals by month

data = [{:label => 'Dec', :value => 11589},{:label => 'Jan', :value => 12222},{:label => 'Feb', :value => 10000},{:label => 'Mar', :value => 8658},{:label => 'Apr', :value => 10500},{:label => 'May', :value => 11112}]

 

@nbr_terminals = {"chart"=>{:exportEnabled=>1,:exportAtClient => 0,:exportHandler=>'/fusioncharts/fc_exporter/index',:exportFormats=>"JPG",:exportAction=>"save",

"caption"=>"Number of terminals per month","setAdaptiveYMin"=>1,"showValues"=>0,"xaxisname"=>"Month","yaxisname"=>"Terminals","thousandSeparator"=>" ","formatNumberScale"=>0},:data => data}

end

 

and a basic view :

 

<%

#Create the chart - Column 3D Chart with data from /Data/SaveData.xml

render_chart "/FusionCharts/Line2D.swf", "", @nbr_terminals, "myFirstExport", 600, 300, false, true, {:data_format=>"json"}

%>

Share this post


Link to post
Share on other sites

Well by making a Sample of my app I found the issue.

 

By default in a RoR app there are those two lines in the application.rb

 

config.autoload_paths += %W(#{config.root}/lib)

config.autoload_paths += Dir["#{config.root}/lib/**/"]

 

For some reason there were missing from mine.

 

Thanks for the help you have provided for the noob that i am :(

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

You are always welcome.smile.gif

 

Glad to know that you have managed to resolve your issue.

 

Happy FusionCharting!biggrin.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now