How to use @rails/activestorage - 10 common examples

To help you get started, we’ve selected a few @rails/activestorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ParamagicDev / snowpacker / test / rails_test_app / app / snowpacker / entrypoints / application.js View on Github external
import "@rails/ujs" // Autostarts
import Turbolinks from "turbolinks"
import ActiveStorage from "@rails/activestorage"
import "../stylesheets/index.css"
import "../javascript"

Turbolinks.start()
ActiveStorage.start()

console.log("Hello from Snowpacker")
github ParamagicDev / snowpacker / examples / rails-without-webpack / app / snowpacker / entrypoints / application.js View on Github external
import "@rails/ujs" // Autostarts
import Turbolinks from "turbolinks"
import ActiveStorage from "@rails/activestorage"
import "../stylesheets/index.css"
import "../javascript"

Turbolinks.start()
ActiveStorage.start()

console.log("Hello from Snowpacker")
github connorshea / vglist / app / javascript / src / components / avatar-input.vue View on Github external
uploadFile(file) {
      this.existingAvatar = null;
      const url = this.railsDirectUploadsPath;
      const upload = new DirectUpload(file, url, {
        directUploadWillStoreFileWithXHR: (xhr) => {
          // Use this workaround to make sure that Direct Upload-ed images are
          // uploaded with the correct header. Otherwise they will end up being
          // private files.
          xhr.setRequestHeader('x-amz-acl', 'public-read');
        }
      });

      upload.create((error, blob) => {
        if (error) {
          // TODO: Handle this error.
          console.log(error);
        } else {
          this.avatarBlob = blob.signed_id;
        }
      });
github connorshea / vglist / app / javascript / src / components / game-form.vue View on Github external
uploadFile(file) {
      const url = this.railsDirectUploadsPath;
      const upload = new DirectUpload(file, url, {
        directUploadWillStoreFileWithXHR: (xhr) => {
          // Use this workaround to make sure that Direct Upload-ed images are
          // uploaded with the correct header. Otherwise they will end up being
          // private files.
          xhr.setRequestHeader('x-amz-acl', 'public-read');
        }
      });

      upload.create((error, blob) => {
        if (error) {
          // TODO: Handle this error.
          console.log(error);
        } else {
          this.game.coverBlob = blob.signed_id;
        }
      });
github Shopify / next-gen-auth-app-demo / app / javascript / packs / application.js View on Github external
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require('@rails/ujs').start();
require('turbolinks').start();
require('@rails/activestorage').start();
require('channels');

// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
require('shopify_app');
// Support component names relative to this directory:
var componentRequireContext = require.context('components', true);
var ReactRailsUJS = require('react_ujs');
ReactRailsUJS.useContext(componentRequireContext);
github exercism / website / app / javascript / packs / application.tsx View on Github external
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@rails/ujs').start()
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('turbolinks').start()
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@rails/activestorage').start()
require('channels')

import 'focus-visible'

// TODO: Let's get all of these loading automatically
// without needing to be specified individually here.
import '../../css/application'
import '../../css/layout'
import '../../css/defaults'

import '../../css/ui-kit/buttons'

import '../../css/components/contributing/header'
import '../../css/components/header-with-bg'
import '../../css/components/exercise-makers-button'
import '../../css/components/avatar-selector'
github mhartl / sample_app_6th_ed / app / javascript / packs / application.js View on Github external
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("jquery")
import "bootstrap"

// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
github davidteren / rails_6_github_template / app / javascript / packs / application.js View on Github external
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import "controllers"
import '../css/application.css'
github imhta / rails_6_devise_example / app / javascript / packs / application.js View on Github external
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")

import '../stylesheets/application'
import 'bootstrap/dist/js/bootstrap'
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
github hopsoft / stimulus_toolbox / app / javascript / packs / application.js View on Github external
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require('@rails/ujs').start()
require('turbolinks').start()
require('@rails/activestorage').start()
require('channels')

// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = name => images(name, true)
require.context('../images', true)

import debounced from 'debounced'
debounced.initialize()

import 'controllers'

document.addEventListener('stimulus-toolbox:set-location', event => {

@rails/activestorage

Attach cloud and local files in Rails applications

MIT
Latest version published 8 days ago

Package Health Score

98 / 100
Full package analysis

Similar packages