Rails CSS & JS with Asset Pipeline

sset pipeline compiles and compress all css and scss into a single file for quick downloads when loaded into production. It also compiles and compresses all of the js files as well.
Last night I was brutalized by the asset pipeline within Rails 3.2.7. I uploaded a new release of a website I’ve been working on only to get a 500 error with a non-descriptive message “Sorry, something went wrong.” I love error messages like that. Tells me exactly where to start looking in troubleshooting. Of course I had modified just about every file in the website, so where to start troubleshooting was the first challenge. There were no entries in the httpd logs and only one line in the app log that an error occurred on retrieving the very first page of the site.

After about 30 minutes of plunking around trying various things to get more descriptive messages to isolate the problem, I decided to revert the way I was calling the stylesheets and javascripts in the app/views/layouts. I had wanted to streamline the css and js files I was pulling down for each request and had changed it to only pull the global css file and the controller specific css file. As soon as I reverted the changes, bam – everything worked.

Asset pipeline in Rails compiles the css and scss files into a single compressed css file. Asset pipeline also does something similar for the javascript files. In development, the development web server does not compress the files, so all the individual files exist and get pulled correctly with my changes. In production since there is only a single file, in essence I was calling a non-existing file.

So how do I continue to have controller specific CSS settings and allow asset pipeline to do what it wants to do. One of the challenges in software development is keeping within the framework you are using so that you can more easily port to new framework versions. So I what I wanted to do was work with asset pipeline and keep the controller specific CSS settings.

I ended up adding a class to the tag in the main app layout. The class is named after the controller. In the scss files for each controller I make sure that all the css settings are under the corresponding body class. This ensure I don’t get a side effect from another controller’s specific css.

The ruby code I added to the application.html.erb layout is:

In each controller’s css file I added the class body.{controller} {}, where {contorller} is the actual controller name. I make sure all of the controller’s css setting are children of this class.

Then in development to clean up the Webrick development server, in Config/Environments/Development.rb I set config.assets.debug = false. This turned off all the asset loading messages.


Yesterday, Tuesday afternoon, we drove down to Puerto Blanc. Puerto Blanc was a small fishing town turned into tourist area and is about 25 kilometers south of where we are staying in Puerto Del Carmen. The marinas and water front dominate the town.

We took a 2 hour tour of the beaches on a Segway. It was only the four of us with our guide. Ultimately I believe our guide took a liking to us, our tour ended being just a little over three hours long. The first hour we spent learning to control the Segway’s under various conditions. The kids took to controlling the machines very quickly.

After our lessons to drive these fun little machines, our guide took us out to two different beaches within Puerto Blanc. Between the beaches we had to drive up and over the cliffs that separated the beaches.

I would highly recommend giving Mario a call at Moving Segway if you want to explore the Puerto Blanc beaches in a unique way.

Dad – What is that?

So I had to explain to my 11 year old what is a pay phone. Pay phones still dominate the streets in the Canaries. As I explained to her what they were and how to use them, I could see the confusion on her face. “Why don’t they just use their cell phones?” was her next question. Most of the people who live in the Canaries really don’t need them. The pace here is very slow and there isn’t a driving need to be that connected. I’ve been finding that a watch is optional here.

El Golfo & Los Hervideros

After visiting Timanfaya, we drove south to the town of El Golfo. El Golfo is where the mineral Olivia was discovered. The town also has a lagoon that is emerald green in color and has black sand beaches.

We were able to purchase some raw Olivia mineral samples so MJ & I can add it to our mineral collection. We started the mineral collection as a project from cub scouts and it has continued to grow over time.

After leaving El Golfo we continued south through Los Hervideros. Los Hervideros is a series of picturesque cliffs along the coast. The views are just out of this world. One only has to press the shutter button on the camera to end up with photos that look like they belong in National Geographic. Truly spectacular.

Timanfaya Camel Ride

Just south of the main entrance to the Timanfaya National Park, there are camel rides up through the park. It is a unique way to see ash fields in the park. The rides take about 30 to 40 minutes. Just long enough to enjoy the ride and see the park in a different way. Just short enough that your not bored.

The camel rides are between the park entrance and the town of Yaiza, about 2 kilometers south of the park entrance. After seeing the vastness of the park from one of the park buses and partaking in the heat demonstrations at the restaurant, the camel ride provided us with the opportunity to see the layers of ash along side one of the cones. It is amazing to see how hard the ash becomes after it settles. It is very similar to pavement.

The camel rides are another must see and must do when visiting Lanzarote.

Timanfaya National Park

Timanfaya National Park is an absolute must see if you ever visit Lanzarote. The park was formed by a volcanic eruption that lasted from 1730 to 1736. There are several cones and miles of cooled lava fields. Not much vegetation has returned to the area over the past 300 years.

As you enter the park, parking is limited. The staff has a car line form at the base of the park. As cars leave, you are allowed to head up to the main parking area. While it seems frustrating to wait at the base of the park, when you are up in the main area, there are virtually no crowds. The total wait was about 40 minutes, which wasn’t all that bad since you are sitting in your air conditioned car.

Once you are at the main parking lot, you take one of the parks buses for a up close tour of the park. The bus tour lasts about 30 minutes. It is fantastic. The bus route takes you through 2 different volcano cones that are currently dormant and down into a collapsed lava tube. The route also takes you over a couple of high points giving you great over view of the park.

After the bus tour, you can view several demonstrations on the amount of heat still being released from some of the volcano vents. At one vent, the staff places some straw into the opening. Within 2 or 3 minutes the straw is ablaze just from the hot air rising from the vent. At another demonstration the staff pours water into steel pipes drilled into the ground about 100 meters. Within a few seconds the water flashes to steam and shoots back out of the pipe with tremendous force.

There is a restaurant, El Diablo, situated in the main parking area of the park. The restaurant uses a volcano vent to grill all of the meats and fish. The restaurant is open only from 12 noon until the park closes at 4:30pm. After the bus tour and demonstrations, we decided to have some appetizers at the restaurant. The food was very good.
Like I said at the beginning of this post, if you ever visit the Canaries, you really need to visit Timanfaya!

Driving from Teguise to Haria

Yesterday, after we left the Teguise market, we drove north up LZ-10 heading toward the town of Haria. Our destination was the Guinate Tropical Park and then El Mirador del Rio. The road wormed its way up through the hills, becoming narrower the further north we went. For a 5 to 7 kilometer stretch the road was just wide enough to qualify as a one lane road. That did not slow down the on coming traffic.

The guard rails, if one calls them that, were about 18″ in height and about 6″ thick. In most places on the other side of the guard rail was a shear drop of 200 to 300 feet. I started to call the road Lanzarote’s death road.

Teguise Market

On Sunday’s, the town of Teguise has an open market. Teguise is situated north of Arrecife on highway LZ-10. It is equally distant from the east and west coast in the interior of the island. It is about a 20-25 kilometer drive from where we are in Puerto Del Carmen.

The open air market takes over the town every Sunday. All the side streets have booths lining each side of the street. Vendors, families and people hawk their goods. Tour operators have special buses to bring in the tourists from all over the island.

We drove up to Teguise to have some fun. We were able to buy a few things that were made on the island. We have no idea if we were able to haggle a good deal or not, but it was a lot of fun trying.

After leaving Teguise, we decided to explore the northern end of the island. We continued our way up LZ-10 through Haria, into Guinate and then into Mirador del Rio.

Math at 8am…Really???

This morning MJ’s smart phone alarm began ringing at 8am. I asked him to set it so we wouldn’t over sleep. I picked up the phone to turn off the alarm. No matter what I did, the alarm wouldn’t shut off. MJ came into the room and took the phone to shut it off. It took him about 5 solid minutes to shut it off. At the time it didn’t make sense why it took so long, but I didn’t question it. I was happy to have the alarm clock go silent.

Tonight at dinner we were talking about the alarm clock and why I couldn’t turn it off. MJ informed me that he uses Alarm Clock Plus. An app were you have to solve a math problem in order to turn off the alarm. He keeps hitting the snooze button on a normal alarm and never wakes up. With this app, he has to wake up enough to figure out the solution to the math problem. Thus preventing him from just hitting t he snooze and not waking up.

While I give him accolades at this solution that works for him, There is just something wrong where I have to figure out a math problem that early in the morning.