Code Snippets HTML+ERB

Short texts HTML+ERB 🧑‍💻 Code snippets HTML+ERB ✍️ Reading lists HTML+ERB 👀

How to save uploaded files to your database in Rails

# db/migrate/20101004063749_create_photos.rb class CreatePhotos < ActiveRecord::Migration def self.up create_table :photos do |t| t.string :name, :null => false t.binary :data, :null => false t.string :filename t.string :mime_type t.timestamps end end def self.down drop_table :photos end end # app/views/photos/new.html.erb {:multipart => true}) do |f| %> # app/controllers/photos_controller.rb class PhotosController < ApplicationController def index @photos = Photo.all end […]

How to save uploaded files to your database in Rails

# db/migrate/20101004063749_create_photos.rb class CreatePhotos < ActiveRecord::Migration def self.up create_table :photos do |t| t.string :name, :null => false t.binary :data, :null => false t.string :filename t.string :mime_type t.timestamps end end def self.down drop_table :photos end end # app/views/photos/new.html.erb {:multipart => true}) do |f| %>

09-user-stats-applictation-layout.erb

# config/routes.rb Rails.application.routes.draw do mount UserStats::Engine, at: “/user_stats” # … end # lib/user_stats/lib/user_stats/engine.rb module UserStats class Engine < ::Rails::Engine # ... config.app_middleware.use( Rack::Static, urls: ["/packs"], root: "user_stats/public" ) # ... end end $ cp bin/webpack* lib/user_stats/bin $ cp config/webpacker.yml lib/user_stats/config $ cp -r config/webpack lib/user_stats/config # Gemfile # ... gem 'user_stats', path: 'lib/user_stats' # ... […]

09-engine-users-index-1.erb

# config/routes.rb Rails.application.routes.draw do mount UserStats::Engine, at: “/user_stats” # … end # lib/user_stats/lib/user_stats/engine.rb module UserStats class Engine < ::Rails::Engine # ... config.app_middleware.use( Rack::Static, urls: ["/packs"], root: "user_stats/public" ) # ... end end $ cp bin/webpack* lib/user_stats/bin $ cp config/webpacker.yml lib/user_stats/config $ cp -r config/webpack lib/user_stats/config # Gemfile # ... gem 'user_stats', path: 'lib/user_stats' # ... […]