-
cd
(changes directory) -
cd ~
(changes to home directory) -
cd ..
(moves up one directory) -
ls
(lists files in folder)
Serving Rails static assets is hard, especially on Heroku Cedar where Heroku forces Rails to serve static assets itself (which isn't particularly performant nor worth your dyno-dollar)---this is different than Heroku Bamboo which used Varnish and is no more. To make the best of the situation, I highly recomend:
-
Using the Heroku-Deflater gem which will selectively gzips assets (it gzips text-based files; and excludes images or binary files, which can actually be bigger when gzipped)
-
Configure your production environment to set cache-control headers and get out of denial about how static assets are being served on Heroku Cedar
-
Use AWS Cloudfront (or a CDN of your choosing) to serve the assets. Cloudfront is great because you can use the same Distribution
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
# app/jobs/example_job.rb | |
class ExampleJob < ActiveJob::Base | |
queue_as :default | |
rescue_from(ActiveRecord::RecordNotFound) do | |
retry_job wait: 1.minute, queue: :default | |
end | |
def perform(param_1, param_2) |
- This is a simple example of setting up Pundit with a standard and headless policy system.
- The
static_controller
is simply a controller that lacks a model and renders static pages, such as a home page, about page, etc. - The
secure
action is just a fill-in example for a page the needs to be secure, it doesn't actually represent a common use case (i.e. you don't need a page called "secure" on a website)
class AddActivatableFieldsToModel < ActiveRecord::Migration[5.0] | |
def change | |
add_column :users, :archived, default: false | |
add_column :users, :test, default: false | |
add_column :users, :dummy, default: false | |
add_index :users, :archived | |
end | |
end |
class AddRolesToUserModel < ActiveRecord::Migration[5.0] | |
def change | |
add_column :users, :roles, :text, array: true, default: [] | |
end | |
end |
class InitialMigration < ActiveRecord::Migration[5.0] | |
def change | |
enable_extension "pgcrypto" unless extension_enabled?("pgcrypto") | |
end | |
end |
Using the "dueling" keyword as an example (from the Getty keywords resource):
{:term=>"dueling", :term_id=>"15115081"}
I am trying to update an existing contribution with the dueling
keyword like this:
{:file_name=>"3_312032_1.mov",
:external_file_location=>"https://s3.amazonaws.com/wpa-getty-assets/3_312032_1.mov",
:headline=>"Gun Fight in the Old West",
# by default you only get 1000 objects at a time | |
# so you have to roll your own cursor | |
S3.connect! | |
objects = [] | |
last_key = nil | |
begin | |
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key) | |
objects += new_objects |