How to change password manually

12/09/17  Public, Command Line, Shortcuts

rails c in development
heroku run rails console in production

If user exists

var = User.first OR var = User.find(id number)
var.password = "password"
var.password_confirmation = "password"
var.confirmed_at = Date.now

var.save

If u...

1 vote - nagano564

Can call multiple `expects` in an `it` block without stopping on failure

11/30/17  Public, Testing / TDD

By adding :aggregate_failures to the end of anit statement, you can call multiple expects in that it block, and if any of them fail, the tests keep testing.

For example, in the this spec, if expect(Post.count).to eq 4 fails, the test ...

1 vote - harrylevine

How to open a link in the same new named tab, every time

11/14/17  Public, Tricks, Other Languages

When you want a link to open up in a new tab, you simply set the target to _blank:

<a href="http://www.starfall.com/" target="_blank">Starfall</a>

But what if you have an index view containing all your Posts, and you want...

1 vote - harrylevine

Set up a Ruby project with RSpec

11/12/17  Public, Ruby General, Testing / TDD

First make sure you have rspec and byebug installed:

➜  byebug -v
  Running byebug 9.1.0
➜  rspec -v
RSpec 3.6
  - rspec-core 3.6.0
  - rspec-expectations 3.6.0
  - rspec-mocks 3.6.0
  - rspec-rails 3.6.1
  - rspec-support ...

1 vote - harrylevine

Disabling and re-enabling a rubocop rule for a specific set of code

11/07/17  Public, Testing / TDD

For example, if this rule is in your .rubocop.yml file:

Style/RedundantSelf:
  Description: Don't use self where it's not needed.
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-self-unless-required
  Enabled: true
`...

1 vote - harrylevine

Checking for rubocop offenses in a given file

11/07/17  Public, Testing / TDD

You can check what is/is not passing rubocop for a given file by calling:

rubocop app/whatever/whatever/my_file.rb

You can get even more output by passing it the -D flag, which adds the actual name of the cop.

rub...

1 vote - harrylevine

When making API call In postman, how to pass a JSON string

11/07/17  Public, Online Resources, Other Languages

  • after selecting POST
  • click the Body tab
  • click the raw radio button
  • select the JSON option from the drop-down
  • add the JSON code

1 vote - harrylevine

Favor everything on HEAD in a Git merge conflict

09/28/17  Public, Git

Let's say that you are rebasing your current branch on master, and you run into merge conflicts. For example with a blog.rb file. If you have a situation where you might be inclined to fix it by:

  • going to master
  • copying the entire ...

1 vote - harrylevine

Drop and recreate a rails database

08/31/17  Public, Databases

This will destroy your db and then create it and then migrate your current schema:

rake db:drop db:create db:migrate

From: https://stackoverflow.com/a/4116124/3899985

1 vote - harrylevine

How to edit the /etc/hosts file

09/06/17  Public, Command Line, Online Resources

https://www.tekrevue.com/tip/edit-hosts-file-mac-os-x/

For example, adding:

127.0.0.1    operationcode-psql 

to your /etc/hosts file enables you to run Rails app that uses Docker, without Docker.

As long as postres app i...

1 vote - harrylevine