Skip to main content

Sending Data Between Controllers And Views | GoRails

General • Asked by Chris Oliver

Simple and concise explanation. Thanks!


Is there a way to pass the variable that was sent to the view back to the controller with a new value?

That's generally not something you would want to do unless you are talking about AJAX. What are you trying to accomplish?

I've written a post about it here http://code.seanosaur.com/r... instead of writing the entire issue out again.

Ah I see now. So the stripe button JS takes an amount simply to display the amount. On the backend, you are always submitting charge for the same amount which is why you're seeing that problem.

To solve this, you want to define some "plans" and submit that to the create action along with the stripe card token. You can do that in hidden fields, but you want to do that instead of submitting the amount so users can't submit their own amount which would be a security issue. If you send over the plan name and look up the amount (you can hardcode this into your app), then you can calculate the appropriate price. Does that make more sense?

Chris, apologies for the extremely late response, but your comment helped me quite bit. Just wanted to say 'thanks!'

3 months later isn't bad on the internet these days. ;-)


Simple and concise indeed, it demystifies the underlying operation of Rails. Good work!


I've just finished going through the Railstutorial by Michael Hartl, and I'd just like to say that your videos (especially these first few) really demystify what is going on under the hood of rails. That is, you've made everything 'click' for me. Thank you!

I'm super happy to hear that! :) Let me know if you've got any other topics you'd like me to explain!


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.