Reputation: 63
I am new to rails, coming in from an angular background. Is there are way to have a button trigger a controller method without having the page redirect? I would also like to somehow tie input fields to controller variables without getting models involved.
What I have is a multi-page form (customer's design, not mine). On each page I want to validate user input, but I don't want to create a model for every field of what will end up being one cohesive object.
Upvotes: 0
Views: 528
Reputation: 577
You can call a controller action using AJAX. Just bind and ajax call on some button's onClick
event and that's it.
Also take a look at remote: true
from jQuery-ujs
You can also validate fields with JS if you don't want to touch models
Upvotes: 1