Answer the question
In order to leave comments, you need to log in
How to pass form field value from React to Ruby?
There is a simple form on the page - written in JS using the React library.
There are several fields in the form (input, checkbox, select...etc).
I need to transfer the value of the shirt_size field (select from 5 possible options) to the Ruby side (using the Ruby on Rails framework)
. On the Ruby side, I need to implement this through a request.
Something similar already exists on the Ruby side.
def ad_size
@ad_size ||= RubyClass::Foo.get(не понимаю что нужно писать сюда)
end
Answer the question
In order to leave comments, you need to log in
Usually, what is written in react does not use the ruby template engine. Therefore, in order to submit something from the form, you need to use the REST API, which is also usually written in the process of moving to React.
Solutions:
a) if everything is clear, search, maybe someone has already started making API and figure out which request needs to be pulled.
b) attach more code if there is still a hodgepodge of templates + react (but this is a road to nowhere)
c) theoretically figure out how applications work in which everything is done on the client (routing + templating), and only requests (REST) fly to the server API)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question