Question

I'm trying to pass an object through a form like this:

<%= simple_form_for :export, url: export_path(format: :xls,data: @result) do |f| %>
 ### fields
<% end %>  

But I'm getting the object as a string and so I'm not able to access it. How do I convert the passed string to object?

I'm getting:

undefined method something for "Mongoid::Criteria:0x00000105f75818":String

Update

I found out that this is a really bad way of passing object via a form. Instead, I sent all the id's concerning the @result object and recreated the result object server side. That solved my problem.

Was it helpful?

Solution

There are few options for you:

  • Don't send the @result via form. Have it in the server(as file/database record) and read only the column list from the form
  • Use only the required string portion of @result in your form
  • If you need the entire object, serialize your @result object and pass via form. Deserialize back in the server. Use something like Marshal.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top