Re: [nesta] Trouble adding images & NoMethodErrors
- From:
- Aaron Stroud
- Date:
- 2010-11-22 @ 16:58
Graham,
Thanks for the quick response.
I just noticed an error in my previous email. Although I said my images lay
in the themes/responsive/public/img folder, they actually were in
themes/responsive/public/responsive/img. I tried using /img and /images for
folder names with no luck. I've also restarted ShotgunWEBrick a few times
which hasn't made a difference. I still get 404 errors when the server tries
to locate the images.
On Mon, Nov 22, 2010 at 12:06 AM, Graham Ashton <graham@effectif.com> wrote:
> On 22 Nov 2010, at 01:40, Aaron Stroud < <astroud@gmail.com>
> astroud@gmail.com> wrote:
>
> (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"
>
>
> You'll need to add a responsive subdirectory inside
> themes/responsive/public, and move your images folder into that.
>
> I realise this is far from intuitive, but it's a result of how Rack::Static
> works.
>
> I wanted to make sure that when somebody installs a theme, that their root
> level public folder is still accessible. That meant that I couldn't allow
> Rack::Static to handle the URL /images; your theme's resources are served at
> /responsive/images, /responsive/foo instead.
>
> Perhaps we should patch Rack::Static so that it's not quite so weird (I
> only just thought of th is option).
>
>
> 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.
>
>
> That's very strange, unless Rack::Static's config has been changed, and
> it's now masking /public.
>
> undefined method `empty?' for nil:NilClass *line: 1*
>
>
>
>
> -
> 1. - unless pages.empty?
>
>
> That can only mean that @articles hadn't been set by the code that ran in
> app.rb.
>
> 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.
>
>
> Yep, you definitely shouldn't have to do that.
>
> 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/>.
>
>
> Which commit were you at when you got the NoMethodError? I'll take a look
> if you give me the sha.
>
>
I just cleaned up my themes app.rb file. Here's the commit
80149d440bb4476185b0<https://github.com/astroud/nesta/commit/80149d440bb4476185b0bd7b21c4e01790381ac6>
.
I tried copying the entire *get "*" do** *code from nesta's app.rb to mine
so I could set* @articles = Page.find_articles[0..7]*, but I get a couple of
errors: my home page renders sans css + gives an error. When I try to view
the apples article it displays correctly, but the css isn't loaded as well.
When I try setting the @articles in *nesta's* app.rb file in the *get "*" do
* method, the pages render flawlessly. So adding that one line is my fall
back option, but I'd prefer to understand why it's not working as it is.
Warmly,
Aaron
> Cheers,
> Graham
>
Re: [nesta] Trouble adding images & NoMethodErrors
- From:
- Graham Ashton
- Date:
- 2010-11-23 @ 14:24
On 22 Nov 2010, at 16:58, Aaron Stroud wrote:
> I still get 404 errors when the server tries to locate the images.
Is the theme definitely enabled? I've checked out your master branch and
curl gives me a 200 response code:
$ curl -I http://localhost:9393/responsive/images/pdf.gif
HTTP/1.1 200 OK
Last-Modified: Tue, 23 Nov 2010 14:10:19 GMT
Content-Type: image/gif
Content-Length: 305
Connection: keep-alive
Server: thin 1.2.7 codename No Hup
I launched shotgun like this:
$ shotgun config.ru
The only thing I had to do to get it to work was to enable the theme in
config.yml (which you've perhaps already done, but config.yml isn't
checked in by default so I haven't got yours from github).
$ ./scripts/theme enable responsive
If you're still having trouble, tar up your local git repo and send it
directly to me (not the list). Also let me know which version of Ruby
you're running it with, and I'll see if I can see anything wrong with it.
Re: [nesta] Trouble adding images & NoMethodErrors
- From:
- Graham Ashton
- Date:
- 2010-11-22 @ 17:09
On 22 Nov 2010, at 16:58, Aaron Stroud wrote:
> I just noticed an error in my previous email. Although I said my images
lay in the themes/responsive/public/img folder, they actually were in
themes/responsive/public/responsive/img.
Okay, I'll grab your repo and see if I can have a look tonight...