I haven’t programmed in a few years and I’m creating a small quiz to help me drill some vocab terms for schoolwork.

In my file quiz.erb, I have the following:
” type=”text” name=”<%= @name %>” value=”<%= @value %>” />
In my main file, it_quiz.rb, I have the questions laid out like this (I’m using Sinatra, by the way):
get '/' do
@title = 'Italian Quiz'
@questions = Hash.new
@questions["a dog"] = ["un cane"]
@questions["a cat"] = ["un gatto"]
@questions["hello"] = ["ciao", "salve"]
@id, @name, @value =
erb :quiz
end
As you can see, I don’t have @id, @name, or @value set to anything. What should I set it to? This project may be a bit over my head, (and I know there are plenty of quiz programs out there that would suffice), but I would really like to learn this.
Melanie,
Glad you’re working on this, it’s always encouraging to me when I see beginners challenging themselves to learn more and solve their own problems with code.
I thought about it a bit, and decided the best way to answer this was with a video, because there’s some context and thoughts that went into some of the decisions, so I thought it would be more helpful if they were captured. This makes the answer less generally useful (people can’t quickly scan some text to find an answer), but it’s a pretty specific question anyway, and so it will probably only be helpful to people in a very similar situation to yours, which means the video is probably more helpful for them, too.
The changes are on github.
Here is the video.
If the stuff where I made classes is beyond what you’re familiar with, then you might find Ruby Kickstart useful, it’s a site I made to teach Ruby to beginners (it might move a bit fast for beginners, but given your question, I’d expect you have have the capacity and tenacity to follow along). It’s free, all the materials are open source and easily accessible.
It also looks like you’re in Chicago, we have a rich Ruby community here in Chicago:
Hope this helps you. Keep at it, you’re doing well and coding is among the most rewarding things you can learn 🙂