# Anchor
click_link 'Save'
# Button
click_button 'awesome'
# Both above
This is another piece of code I've extrapolated from a Ruby on Rails project I'm currently working on. The code implmenets social login with a RoR API-based application, targeted at API clients.
The setup does not involve any browser-redirects or sessions as you would have to use working with Omniauth.
Instead, what it does is takes an access_token generated on client-side SDKs, retireves user info from the access token
and creates a new user and Identity
in the database.
This setup works with native applications as described in the Google iOS Sign In Docs (see Authenticating with a backend server)
Run rails new --help
to see all of the options you can use to create a new Rails application:
Output for Rails 7+
Usage:
rails new APP_PATH [options]
Options:
[--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated engines)
I wrote this gist because I felt that the Rails documentation was lacking a description of ajax requests.
There are various ways to send ajax requests in Rails.
- Browser default Fetch API
Rails.ajax
(No Official docs and request for docs)- http client like axios
- @rails/request.js 👈 I'm using this one now !
import { Inertia } from '@inertiajs/inertia' | |
import { onBeforeMount, onBeforeUnmount } from 'vue' | |
/** | |
* @param {() => boolean} shouldBlockUnload | |
* @param {string} message | |
* @returns void | |
*/ | |
export function useBeforeUnload( | |
shouldBlockUnload, |