For a recent Rails project I had the following setup:
class Pager < ActiveRecord::Base
# rest ommited for brevity
In my view, I want to select 0-n users. Actually the first challenge was to create the checkboxes in a way the selected options get submitted as an array. It’s been ages since I last used checkboxes!
<input type="checkbox" name="pager[user_ids]" value="1">
<input type="checkbox" name="pager[user_ids]" value="2">
<input type="checkbox" name="pager[user_ids]" value="3">
This way, the selected user IDs will get submitted as an array.
The next problem was Strong Parameters. Even though I added
permit(:user_ids), I got an Error message saying something aling “Parameter ‘user_ids’ not allowed.”.
Digging in the API from ActionController::Parameters I discovered that only some scalar types are allowed. To allow Arrays, they have to be declared as such:
If you’re new to Strong Parameters, I highly recommend reading Strong Parameters by Example by sensible.io.
I’m currently looking for the
best least expensive way to host some of my private small-scale Rails-projects. I’m only expecting a handful of users, so performance really isn’t an issue
These are my requirements:
- Runs Rails apps (ha.) One web process, one background worker job at least.
- Includes a small DB, either separately installed or as an addon.
- DNS is also required
This are the options I’m gonna look at:
- Self-hosted on a Linode*
- Self-hosted on Amazon AWS
- Hosted on Heroku
The smallest Linode you can get is a 1 GB VM. Traffic is free for up to 2 TB per month (which should be plenty), and it also included is a full featured DNS.
The price tag is $20 per month.
Here again, the smallest node you get is a the t1.micro instance. They are… complicated. They’re not meant to do the heavy lifting on an Application, but they fit my needs.
I used the AWS monthly calculator tool to estimate the costs for this type, and came up with about $16 per month.
If you don’t know Heroku yet, you should really check out the Heroku website! It is awesome!
One thing to note here is that it actually runs on AWS.
Running an app on heroku with 1 web and 1 worker dyno costs you $35 per month.
While AWS is the least expensive option, it is also the worst, performance wise. There isn’t much difference to Linode (price-wise), but you’ll get more bang for the buck at Linode.
On the other hand, while Heroku is the most expensive option, it is also the most comfortable one. No setting up, no configuring stuff or updating servers, just you running your app.
*) Yes, this is a Referral URL as I'm already a happy Linode customer. No, this post is not sponsored by anyone (Sadly. Boo!)
months years of procrastinating, I finally built this thing.
While some content is still missing (like the About Page) and parts are falling off here and there, I’m proud to be at least somewhere.
Thanks to the help of Jekyll, Github Pages, Twitter Bootstrap and many helpful people out there I did most of the “work” in just 1 or 2 days.
(Why did I always want to build my own Website with Rails?)
While I work on the small things (like comments and so) feel free to contact me at manuel.hutter at gmail.com or a social network. (see header)
BTW, is it a bad habit to misuse a Issue tracking system as a ToDo-List?
Customize HTML for your theme, add this at the end of
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet"/>
Add this to your Body-Tag:
Done. To actually make use of it, you’ll have to use the HTML-Editor. I recommend the following (HTML5) convention:
<pre class="prettyprint"><code class="language-java">...</code></pre>
Recommended Add this to your custom CSS:
If you want a transparent background, add this inside the curly braces:
Optional To use a Theme, download the desired CSS file (or create your own), upload it to Tumblr and replace the default CSS file in step 1 (blabla…prettify.css) with the URL of your uploaded file. DONE!
(distilled from /dev/null’s post on this topic)
I am Dyslexic of Borg. Fusistance is retile. Your ass will be laminated.
user@host:~ $ npm install coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN
npm ERR! at ClientRequest.<anonymous> (.../lib/node_modules/npm/node_modules/request/main.js:483:26)
npm ERR! at ClientRequest.g (events.js:156:14)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
npm ERR! at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:91:29)
npm ERR! at CleartextStream.socketOnData [as ondata] (http.js:1288:20)
npm ERR! at CleartextStream._push (tls.js:375:27)
npm ERR! at SecurePair.cycle (tls.js:734:20)
npm ERR! at EncryptedStream.write (tls.js:130:13)
npm ERR! at Socket.ondata (stream.js:38:26)
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <firstname.lastname@example.org>
npm ERR! System Linux 188.8.131.52-0.3-default
npm ERR! command "node" ".../bin/npm" "install" "coffee-script"
npm ERR! cwd /home/user
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.21
npm ERR! message SSL Error: SELF_SIGNED_CERT_IN_CHAIN
npm ERR! Additional logging details can be found in:
npm ERR! /home/user/npm-debug.log
npm not ok
user@host:~ $ npm config set strict-ssl false
user@host:~ $ npm config set registry="http://registry.npmjs.org/"
Tested under Ubuntu 10.04 LTS and SLES 11 SP1 so far
- Custom CA-Cert available as DER file (*.cer)
# Step 0: Convert the Certificate to PEM format
$ openssl x509 -inform der -in certificate.cer -out certificate.pem
# Step 0.5: Make sure there is only 1 Certificate in the File
$ grep 'BEGIN.* CERTIFICATE' ProxyCA.pem | wc -l # should output `1`
# Step 1: Verify it's the correct Certificate
$ openssl x509 -noout -fingerprint -in certificate.pem
# Step 2: Copy the File to /etc/ssl/certs
$ # Do I really have to explain that? If you can't do that on your own you probably shouldn't be installing CA-Certificates anyway...
# Step 3: Find out the Hash of your Cert
$ openssl x509 -noout -hash -in certificate.pem
# Step 4: Inside /etc/ssl/certs, link your certificate to "hash.0"
$ ln -s certificate.crt `openssl x509 -hash -noout -in certificate.crt`.0
Because the solutions I googled didn’t work:
for g in `gem list --no-versions`; do
gem uninstall --all --ignore-dependencies --executables $g