this gist contain my notes from developing apps with ruby on rails framework correction / suggestion are welcome, thank you
rails using technique called 'unobtrusive javascript' for handling most of their javascript unobstrusive is just a way to remove inline javascript trigger event ( like click ) to separate js using data- attribute Notes on flash message
- put flash message inside div with id ( e.g #notice ) and make it partial ( shared/flash_message )
- give form_with a local:false
- or remote: true to button_to method
- make file action_name.js.erb ( or whatever the action_name called )
- then put this inside action_name.js.erb
$('#notice').html("<%= j render 'shared/flash', flash: flash %>");
- the action will render flash message, and we can get the message / status via flash: flash ( local )
- replace dom that change using dom_id helper, or some id of your own