Note: This post is a summary of information paraphrased from an excellent blog post by Christian Sepulveda.
Create the app and download the necessary dependencies.
| function logColor(color, args) { | |
| console.log(`%c ${args.join(' ')}`, `color: ${color}`); | |
| } | |
| const log = { | |
| aliceblue: (...args) => { logColor('aliceblue', args)}, | |
| antiquewhite: (...args) => { logColor('antiquewhite', args)}, | |
| aqua: (...args) => { logColor('aqua', args)}, | |
| aquamarine: (...args) => { logColor('aquamarine', args)}, | |
| azure: (...args) => { logColor('azure', args)}, |
Create the app and download the necessary dependencies.
gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).
Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.
When you read about how to create and consume a pre-signed url on this guide, everything is really easy. You get your Postman and it works like a charm in the first run.
Then you open your browser, try your usual $.ajax() and send your PUT operation, and you hit the cold iced wall of AWS error message, a simple <Code>SignatureDoesNotMatch</Code> that will steal hours from your productivity.
So here I come to save you and give you a free working example of how to upload a file directly to AWS S3 from your browser. You are wellcome :).
| <script charset="utf-8"> | |
| <% if ENV["RAILS_ENV"] == "production" %> | |
| var script = "/react-app-bundle.js"; | |
| <% else %> | |
| console.warn("Development mode. Make sure to start 'node devServer.js'"); | |
| var script = "http://" + (location.host || 'localhost').split(':')[0] + ":4000/react-app-bundle.js" | |
| <% end %> | |
| document.write('<script src="' + script + '"></' + 'script>'); | |
| </script> |
| require 'rails_helper' | |
| RSpec.describe TodosController, :type => :controller do | |
| describe "GET #index" do | |
| #describe "POST #create" do | |
| #describe "GET #show" do | |
| #describe "PATCH #update" do (or PUT #update) | |
| #describe "DELETE #destroy" do | |
| #describe "GET #new" do |
This is a quick tutorial explaining how to get a static website hosted on Heroku.
Why do this?
Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.
#Simple Authentication with Bcrypt
This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.
The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).
You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault
##Steps
| var app = angular.module("modalFormApp", ['ui.bootstrap']); | |
| app.controller("modalAccountFormController", ['$scope', '$modal', '$log', | |
| function ($scope, $modal, $log) { | |
| $scope.showForm = function () { | |
| $scope.message = "Show Form Button Clicked"; | |
| console.log($scope.message); | |
| var modalInstance = $modal.open({ |