0

Problem:

I want it to be able to pass the return value into an HTML ERB page(see result form below). I have tried many of the solutions on here and other sites and have yet to find one that fixes my problem. I included the full code in case I missed something.

NOTE: I get the return value and can bring up the results form but the return value is not passing. I already posted this but solution given did NOT help. This includes the change recommended to me. It appears adding #{output} so the redirect in the main code causes a "The connection was reset" error which makes no sense what-so-ever.

Main Code: file name: */projects/webhosted_custom_fibonacci_calculator.rb

require "rubygems"
require "sinatra"
require_relative 'fibonacci_calculator.rb'
require "erb"


include Calculator


get '/' do
    redirect ("/calculate")
end

get '/calculate' do
    erb :calculator_form, :locals => {:calculator => session[:calculator]}
end

post '/calculate' do
    num1 = params['firstnum'].to_i
    num2 = params['secondnum'].to_i
    output = Calculator.run(num1, num2)
    redirect ("/results_form?results=#{output}")
end

get '/results_form' do
    erb :results_form, :locals => {:results => params[:results]}
end

Result form: File name: */projects/views/results_form.erb

<html>
    <head>
        <title>Fibonacci Calculator</title>
    </head>

    <body>
        <h1>Results</h1>
        Result: <%= results %>

    </body>
</html>
  • Have you tried an `@instance_variable`? – Dan Grahn Jul 16 '13 at 19:50
  • thanks for the idea. tried it and it will now show the form but not put the return value into the form. it appears that the redirect only allows us to pass static information and i tried the @@variable (global variable) to see if that would work and that did nothing – user2587507 Jul 16 '13 at 20:11
  • [This is all I got](http://stackoverflow.com/questions/6737889/passing-parameters-to-erb-view). – Dan Grahn Jul 16 '13 at 20:13

0 Answers0