Skip to content

Instantly share code, notes, and snippets.

@ShepBook
ShepBook / gist:dcd4e3c312acf1f6e096
Created June 13, 2014 03:31
Update form_for without password
Originally from http://stackoverflow.com/questions/7083575/updating-user-attributes-without-requiring-password/8790881#8790881
The correct answer no-longer works for rails 4. I believe my answer is the cleanest and the most versatile that will work whenever you want to leave out any attributes (not just the password). This approach will be needed if you want to update the separate attributes of any model in a number of different places.
For example, if you want to do what Stack Overflow does and have the passwords updatable via a security page, the profile image updatable via the user show view and the bulk of a user's information updatable via a user edit view.
1) Extend the hash class with a class method to delete blank values. We will use this method to remove blank values that are not being updated but are still present in the params hash:
1a) Create a hash.rb file in your lib directory, under an ext directory:
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
@ShepBook
ShepBook / gist:6214168
Created August 12, 2013 19:20
Purge all gems.
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@ShepBook
ShepBook / gist:5713899
Last active August 22, 2020 06:35
Installing Clojure and Clojure Koans with Leiningen on Linux Mint 15

Installing Clojure and Clojure Koans with Leiningen on Linux Mint 15

Remove Existing OpenJDK

Generally, I'd recommend running Oracle's Java, if you're doing Clojure development. Seeing how Clojure is built around the standard JVM from Oracle, it seems like it would be best to use that. First, let's remove the existing OpenJDK from our OS.

Search for OpenJDK

$ dpkg --get-selections | grep jdk

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev