I'm new to Ruby so please excuse my ignorance. I really didn't know how to word this question so this may also be part of the reason I haven't found an answer online.
I'm working with Rho Elements, and I'm trying to pass something from one page to another. I've made some good headway but run into something that I do not understand. I can pass through an ID like so
<input type="hidden" name="id" value="<%= @orderdetails.object %>"/>
I then grab the ID(only doing this right now to make sure I do get the ID)
@id = @params['id']
then redirect to another page
redirect url_for(:action => :newpage, :id => @id).
This is where my problems start. When I debug the application I get past the redirect and enter :newpage
def newpage
@orderdetails = OrderDetails.find(@params['id'])
if @orderdetails
render :action => :newpage, :back => url_for(:action => :index)
else
redirect :action => :index
end
end
Once here I check
@params['id]
and this is what is displayed.
@params {"id"=>"{131113212443313.17}"}
"id" ""
@params {"id"=>"{131113212443313.17}"} is shown by eclipse and when I break into the variable "id" "" is shown.
Why can I see the ID that I want to use to grab the orderdetails that was just created but also have the actual variable be empty?
**EDIT: This is the information I'm trying to pass.
@params {"id"=>"131113212443313.17", "next"=>"asleftnext", "orderdetails"=>
{"AsFoundMeterRead"=>"", "AsFoundImage"=>""}}
"id" "131113212443313.17"
"next" "asleftnext"
"orderdetails" {"AsFoundMeterRead"=>"","AsFoundImage"=>""}
Use params
in the controller, not @params
. Also the canonical form of accessing keys is params[:id]
.