librelist archives

« back to archive

Trouble adding images & NoMethodErrors

Trouble adding images & NoMethodErrors

From:
Aaron Stroud
Date:
2010-11-22 @ 01:40
I've been using nesta the past few days and it's been a lot of fun. I'd like
to use it on a couple of projects. However, I have hit a couple of
roadblocks that I haven't been able to make sense of.

(1) My theme's graphics in my

themes/responsive/public/img<https://github.com/astroud/nesta/tree/master/themes/responsive/public/responsive/img/>folder
are not being used. I've set my

themes/responsive/app.rb<https://github.com/astroud/nesta/blob/master/themes/responsive/app.rb>file
as instructed (see below), but my development machine (OS X) and
heroku <http://simple-beach-33.heroku.com/> still can't locate the images.

use Rack::Static, :urls => ["/responsive"], :root =>
> "themes/responsive/public"


For a while, I kept the graphics in nesta's public folder so I could
continue converting my html/css design to haml/sass. And that worked
initially, but it suddenly stopped working on heroku this afternoon, so I
decided I needed to get to the bottom of the problem before proceeding
further.

(2) My other problem has to do with an undefined method error. I cut and
pasted and then edited the summaries.haml code into a new
recent_articles.haml file that I call in the sidebar.haml. After I
introduced this code, I started getting the following NoMethodError:

undefined method `empty?' for nil:NilClass        *line: 1*




   -
      1. - unless pages.empty?
   1. %ul
      2. - pages.first(3).each do |page|
      3. %li
      4. %a{ :href => page.abspath }= page.heading
      5. - if page.date
      6. = "   " + format_date_recent_articles(page.date)



I call the recent_articles.html the same way the summaries.haml was called
(see below) so I am at a loss for why I'm getting the error.

= haml :recent_articles, :layout => false, :locals => { :pages => @articles,
> :heading => :h2 }


I was able to get around the problem by copying nesta's *entire* app.rb file
into my app.rb file which solved the problem. But that isn't a very elegant
or DRY solution. Plus, it makes it harder to keep track of the methods I've
tweaked or added.

I only have little ruby and rails experience and would appreciate someone
pointing out why I can't move the summaries code into a new file without
causing these errors. The site deployed
here<http://simple-beach-33.heroku.com/>and here's
the repository on github <https://github.com/astroud/nesta/>.

Thanks in advance,

Aaron