Photo by Matthew Henry on Unsplash

When refactoring a Ruby on Rails project to incorporate JavaScript views, I wanted to use a helper method (for formatting a phone number) located in the app/helpers directory.

# app/helpers/reqeusts_helper.rbmodule RequestsHelper
def formatted_phone(string)
phone = string.insert 3, "-"
phone.insert 7, "-"
end
end

I ran into a problem using the method directly as a helper. I solved the problem by moving the method to the Request model and serializing the returned value (along with the other attributes). Since this method will be called for all requests, I added a simple check for the presence of a user’s requestor_phone property.


“assorted-color animal toy lot” by rawpixel on Unsplash

It’s nice to have options. Enter Ruby on Rails’s collection_select form helper. It generates an HTTP <select> tag and <option> tags that render a dropdown menu with multiple options

(Note: the helper method collection_check_boxes and collection_radio_buttons are similar, except they display each collection item with a checkbox or, you guessed it, a radio button.)

Generally…

This code:

collection_select(object, method, collection, value_method, text_method)

Creates HTML that looks something like:

<select name="object[method]" id="object_method">
<option value="value_method">text_method</option>
<option value="value_method">text_method</option>

...

Each item from the collection array is represented by an <option> tag. You can access the value_method of the submitted info through the params hash.


“bowl of tomatoes served on person hand” by Elaine Casap on Unsplash

We Americans waste 25 to 40% of all our food. It’s taking over our landfills, releasing environmentally harmful methane gas. Food insecurity is another major issue we face. 1 in 8 of us is food insecure, lacking consistent access to enough food. On the other hand, some of us have too much. Every week my friend buys a pizza, and every week there are 2-3 large slices that grow lonely and old in the fridge. What if every week he could donate a few fresh slices to a hungry person (me for example)? What if a family could enjoy the…


“A little boy holding a book with a surprised expression on his face” by Ben White on Unsplash

You learn something new every day, they say. For me this has been especially apparent lately as I venture into new (to me) coding territory with the Flatiron School. I reached my second of five portfolio projects, and it’s an exciting time for a nerd like me. The project is a chance to build something that’s totally me, to explore, to dive deeper.

I’ve been thinking a lot about time. The more it passes, the faster it seems to slip by. Summer is on the downswing already. Pumpkin spice is back in a week and sweater weather is most likely…


For the final project in the Ruby object-oriented programming unit in Flatiron School’s Online Web Developer program, I am building command-line interface data gem. I’m incredibly excited to have a personalized project. Where else can you visualize something you wished existed and then bring it into existence? Bringing an app to life from a blank screen in a text editor feels almost like a violation of the first law of thermodynamics. Somethingness emerging from nothingness!

Photo by Daniel Cheung on Unsplash

After an excessive amount of brainstorming with a friend, I settle on building a gem that spits out a random book excerpt and gives the…

Theresa Morelli

Studying web dev at Flatiron School

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store