Skip to content

Instantly share code, notes, and snippets.

@RyanB1303
Last active April 16, 2022 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanB1303/67a070ec6867f5ff221462bd5ac68efd to your computer and use it in GitHub Desktop.
Save RyanB1303/67a070ec6867f5ff221462bd5ac68efd to your computer and use it in GitHub Desktop.
rails development notes

Ruby on Rails notes

this gist contain my notes from developing apps with ruby on rails framework correction / suggestion are welcome, thank you

JavaScript on Rails

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment