Been a while, hasn’t it? Anyway, I’ve finally had a bit of time now to sit down and revisit the tutorial.
The next steps in the tutorial (the link is here if you’re interested) are regarding adding picture/file uploads to the server (so, section 4). This bit started off pretty simple. I did hit that one error they warn you about, where the uploader cannot be found and you need to add another gem, but that only added a step that was basically identical to the one before it, so it was fine.
The only major snag I hit was in the step which has you add the code showing the picture (rather than just its filepath).
They ask you to change
<%= idea.picture %>
to
<%= image_tag idea.picture_url, width: '100%' if idea.picture.present? %>
Which for some reason generated astronomical amounts of errors. The reason is probably that I did a lot of things wrong. The first error was caused by referring to a local variable as an instance variable (Ruby differentiates these by starting instance variables with an @), but I tried to fix that by using some of the formatting from a different edit RailsGirls had me make, assuming that they had just messed up their second instruction.
<%= image_tag(@idea.picture_url, width: 600) if @idea.picture.present? %>
Doing this did not actually fix the problem. It made it worse.
I decided to debug by adding this as an extra list item, rather than replacing a list item already present, so that I could narrow down where the issue might be coming from. Naturally, I messed up the HTML tags immediately and caused a new issue.
But! I found that problem almost right away, got that cleared up, double checked why/how the parentheses might be working or not working, realized that the @ symbol shouldn’t be there, removed that and the parentheses, and everything started working again.
Verdict: I need to review Ruby syntax.
The static pages and routes finetuning were very easy, and I didn’t run into any issues there, which means that I finished that section of the tutorial today! The next section is about pushing your work to GitHub, but I don’t think I’ll do that right away; I want to do a bit of monkeying around with HTML, CSS and Javascript before I push anything.
Onward!
Leave a Reply