No return value in rails console
A quick tip when working in rails console. If you're testing commands to run and don't want the console to output the return value, just append a semicolon to your ruby code.
User.all
# => [#<user:0x007fd72a408630> {:id => 1, :name => "Mr. T", ...}, tons and tons of other records]
User.all;
# => nothing!
OK, so that's a contrived example, but this really comes in handy
- when creating records, or
- if you need to update several records in one shot and don't want to see the return values, or
- POSTing to an external API and avoiding all the cruft that comes in the response