Ask A Question

Notifications

You’re not receiving notifications from this thread.

update a model attribute with the ujs ?.

yuvsaha123 asked in General

Hello,

have a page that displays games(model) with a select box for the game result outcome. Game model has_one :result, autosave: true and
I have a unique id for each row in the table based on the game id and I am using materialize rails which attaches a class of "active selected" to whichever choice is selected in the select dropdown(these correspond to the enum keys. i would like to use ujs to update the result whenever the user selects from the select dropdown. I am haven't done much with ujs in rails but it seems like it should be fairly simple. Can anyone give some guidance on how this would be setup?
result model has:

enum outcome: {
undecided: 0,
white_won: 1,
black_won: 2,
white_forfeit: 3,
black_forfeit: 4,
draw: 5,
}

thanks
yuvsaha

Reply

This should enable you to utilize ujs in Rails to update the result whenever the user makes a selection from the select dropdown.

Reply

As a result, you should be able to use ujs in Rails to update the result anytime the user makes a choice from the select dropdown.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,387+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.