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:
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:
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: I can’t get my image to work in my project, why not?
A: Files ending in the .jpeg extension won’t be recognized by the asset pipeline. But if you change the file extension to .jpg, they should work.
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:
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. When I try to start the server, I get an error message about a pending migration. What should I do?
A. Try running rails db:migrate first to run any pending migrations. If that doesn’t resolve the issue, do the sequence: rails db:drop to get rid of your development and testing databases, then run rails db:migrate to run all of your existing migrations.
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
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
Q. I get an error message in AWS Cloud 9 that I am running out of space. What can I do?
A. There are a variety of strategies that students are using when receiving this error:
- Do not install ruby’s documentation. The command to do this is in Listing 1.1 of Hartl. Note: if you forgot to do this when creating your environment, you may need to create a NEW environment and start again.
- Limit your time when editing in the AWS Cloud9 IDE to an hour per session. This should limit the build-up of large working files since those are supposed to be cleared out between log ins. It could take 30 minutes, however, for the environment to stop and clean out.
- Increase your EBS volume size: https://docs.aws.amazon.com/cloud9/latest/user-guide/move-environment.html#move-environment-resize
- Ask the AWS support for an increase: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/requesting-ebs-volume-modifications.html
- Apply for AWS Education program. This seems to increase your environment size and gives you a sizeable credit budget for AWS services. However, you need to use your Grinnell school email account and once you use your budget, the account will be terminated. It may take more than a day to get approved. So, if you are experiencing technical difficulties, email your instructor.
Q. I copied some code from the Hartl tutorial but it doesn’t work in my project, especially after I push to Heroku.
A. The AWS Cloud9 IDE editor seems to have trouble with code that is cut and pasted into a file. This is especially a problem with quotation marks. Usually, erasing the quote marks (single or double quotes) and retyping them seems to fix the problem.
Q. I get an AWS Environment Error when I try to start working on Homework 1. It says that it is unable to access my environment.
A. Check what browser you are using. We’ve had report of this error when using Safari (although Safari is officially supported by AWS Cloud 9).