Frequently Asked Questions

Q: I can’t think of an idea for my individual project.

A: That’s not really a question, but we’ll go with it :). You could base your project around a dataset that interests you from Kaggle or UCI. The first few homeworks won’t require you to include the dataset, but you’ll learn how to include it in Homework 7.

Q: How do you override the colors of the nav bar in Bootstrap?

A: In your custom.scss page, you can override the Bootstrap class:

.navbar.navbar-fixed-top.navbar-inverse {
background-color: pink;
}

Note: the periods and that there are no spaces between sections of the class definition.  This is not an optimal solution, but it is quick and will do the job for now.

Q: I followed the Hartl CSS section, how do I change the inner box color? I can’t find that in the CSS tutorials anywhere!

A: That is a feature of Bootstrap and so you need to look in the Bootstrap documentation specifically. You’ll find the tags “.navbar-default” and/or “.navbar-inverse” and “.jumbotron” helpful in changing the color scheme of the Hartl default page. The inner box is the jumbotron.

Q: My navbar is hiding content on my page. I have the padding-top in my CSS but it doesn’t seem to do anything.

A: While whitespace doesn’t matter for most of CSS, it does when specifying the pixel size of padding, so it must be 60px NOT 60 px to work. Working example:

body {

     padding-top: 120px;

}

Q: When I tried to install Heroku command line tools it was stopped by my virus protection, what do I do?

A: If you can tell your virus protection to ignore it, do so. If you can’t because you are using a campus machine and Traps stopped it, it should be overridden within a business day. You can also ignore Heroku command line tools and have Heroku integrate with Github instead.

Q: My background image is showing up when I run the server locally but then doesn’t show up on Heroku, what is going on?

A: In your CSS file, you need to have image-url(“image.png”) and the image needs to be in app/assets/images. What is happening is that Heroku ‘helpfully’ changes the names of images so that browsers reload them properly if you’ve changed the image but kept the same file name. This means that when your stylesheet tries to find a specific image, it isn’t named what it expects. The image-url handles this where just url doesn’t. This is true of any assets, so even if it isn’t your background image, the image-url is still needed wherever you are including an image.

Q: I’m following the Hartl tutorial and trying to change my CSS, but I can’t get a background-color style to work for my footer, why isn’t it working?

A: You probably need to add the ‘container’ class to your footer either with a div tag or directly to your footer tag.

Q: All my link_to links are being called twice, how do I fix it?

A: This is caused by an issue in the Turbolinks gem, see here to opt-out of turbolinks on specific links.

Q: I followed the tutorial on doing a random die roll for my dynamic content in HW 4 but how do I test that?

A: To test that the variables set in a controller were set correctly, you should use the rails-controller-test gem, specifically if you had:

@result = 1

in your controller action, you can check that in a test using assigns:

assigns(:result)

You can also access the variables in assigns because it is a hash: assigns[:result].

The documentation for the gem has a more fleshed out example.

Q: Help, during the usability lab I got stuck on Amazon.com/access and can’t turn it off!

A: Scroll to the bottom of the page (past the constant scrolling ‘feature’) to the footer. In the footer there is a link to the Desktop site that will set you back to the Amazon.com homepage you are used to.

Q: When I’m trying to display the contents of my database locally, it isn’t working but I can’t tell why, what should I do?
A: Try adding debug parameters and byebug debugger as described in Hartl 7.1.

Q: My database information shows locally but when I push to Heroku it doesn’t show up!

A: You need to migrate and seed your database on Heroku just like you did locally. To do that you can use Heroku command line tools to run heroku run rails db:migrate and heroku run rails db:seed. (If you didn’t make a seed.db, you should go back to the homework resources and do that.) If you aren’t using Heroku command line tools, you can run the same commands on Heroku.com by using the More dropdown and selecting Run console and entering the same commands.

Q: I’m trying to pull a random entry from my database and it works in development/production but not in testing. I have a fixtures file with dummy data, but ActiveRecord can’t find the entry by ID, what is going on?

A: The fixtures file that is automatically generated doesn’t include an id field, so if you are trying to find a record by ID in your testing environment, it won’t work. You need to add an id field to your fixture.

Q: I can’t get my app to run on local host and it complains that gem X is missing.

A: This could be caused by a few different issues, but check your Gemfile first.  Be sure you do NOT have two groups with the same name.  It seems to read the first one and ignore the second, which will mean that some (probably really important) gems will not be installed.  Then, run bundle update and bundle install

Q: I installed ActiveAdmin and it changed the style of my website, how do I fix it?

A: You should move the generated file active_admin.scss from app/assets/stylesheets to vendor/assets/stylesheets. (Source)

Q: I’m trying to change the content of my view after a user submits a form using form_with, but the HTML isn’t changing when it renders, what’s going on?

A: form_with assumes that you will use AJAX, so if you aren’t, you need to tell it that like this:

<%= form_with model: @user, local: true %>
<% end %>

See this article for more details: Medium form_with post

Q. I updated or installed a program using brew on my Mac OS machine, and now when I try to do anything with rails, it spits out a long list of error messages and says it cannot find the openssl library.  How do I fix this?

A. Brew will add the newest version of openssl and remove old symlinks to it.  I tried many different solutions, but the one that finally worked was to tell brew to switch back to the old version.  First thing is to find out which version was the working one with

ls -al /usr/local/Cellar/openssl

Mine happened to be version 1.0.2s.  And once you have the version number, use that in the command similar to:

brew switch openssl 1.0.2s