mangling arrays

11/07/14  Public, Tricks, Ruby General

To take an array like:

[1, 3, 'two', 5]

and have it result in an array of pairs such as:

[[1, 3], 'two', 5]]

You can use each_slice method.

array.each_slice(2)

Provided, of course, that array is assigned the original ...

2 votes - kotp

Determine what gems in your project have newer versions available

11/08/14  Public, Rails General, Gems

Run bundle outdated

To help decide if you want to take action and update a particular gem, view the gem's changelog.

For example, if there is an updated version of Devise available, Google devise changelog to determine what has been ch...

1 vote - harrylevine

Updating Rails version for a patch update, i.e. from 4.1.1 to 4.1.7

11/07/14  Public, Command Line, Rails General, Gems

  • Create a new branch
  • update the gemfile to gem 'rails', '4.1.7'
  • run bundle
  • this may show conflicts in other rails dependencies like
    • actionview, actionpack, actionmodel, etc
  • in order to update these Rails associated items, and...

1 vote - harrylevine

Rails command for generating a Model with columns and references

10/30/14  Public, Command Line, Rails General

$ rails generate model User name:string age:integer vote:references post:references

the model name is Capital and singular (i.e. User)

Use vote:references and post:references in your generator to add the foreign IDs into User table, to...

1 vote - harrylevine

Job websites for 100% remote work

12/15/14  Public, Online Resources

https://remotecoder.io/

https://weworkremotely.com/

2 votes - harrylevine

Ways to create test email addresses

10/28/14  Public, Tricks, Testing / TDD

1) You can add a “+” sign right after your email prefix, and then add anything after that, between the + and the @, and it will create unique test emails address. All of which will be emailed to your original address.

For example, if your emai...

1 vote - harrylevine

Applying a focus during rspec testing to test just one specific area

11/24/14  Public, Command Line, Testing / TDD

add , focus: true on the area to be tested. You can use any word here, instead of focus. (i.e. foobar)

describe "the root page", focus: true do
  visit "/"
end

Then to run the rspec on just that focussed area you type in...

1 vote - harrylevine

How to run a spec / test when there is a time latency or lag involved

10/28/14  Public, Testing / TDD, Gems

For example, if something is supposed to automatically delete every 7 days, how do you test for that?

Two ideas

  1. You can manually changed the created_at data in the database to back date an item, simulating it was created 7 days ago

...

1 vote - harrylevine