Uko
Uko

Reputation: 13386

Persist data between controller methods with non-table model?

I have an app that makes graphs depending on entered text.

And I'm making it pseudo-REST as I have a form for entering text in #new and I want to run all calculations it #create and then show output on #show but I'm not using any storage, so data calculated in #create should be somehow passed to '#show' and it looks like a bad idea to put it in session. Is there any option to persist data just for redirection to other method?

Upvotes: 1

Views: 162

Answers (2)

Uko
Uko

Reputation: 13386

Eric Sites gave a very good answer, but I want to show the other point of view concerning REST idea.

As I've said in the question: I'm not saving and data e.i. creating resources. So I suggest to send the data from form directly to #show and preferably by GET.

This way #new action will give you form for a new resource and #show action will show you resource specified by URI and constructed on the fly

Upvotes: 0

Eric Sites
Eric Sites

Reputation: 1534

In you def create function instead of redirecting to show why not just do this:

render "show"

Upvotes: 2

Related Questions