Thanks Jenna, this works great! I think I understand how the R
constructor works a little more now...

On Wed, Feb 9, 2011 at 5:23 PM, Jenna Fox <a...@creativepony.com> wrote:
> class LoadScript < R '/(.*).js'
> def get(script)
> @headers['Content-Type'] = 'text/javascript; charset=utf-8'
> return File.read("my scripts/#{script}.js");
> end
> end
> Keep in mind the R constructor takes a regexp, and passes the bracketed
> sections as arguments to the get, post, put, etc... methods on the class
> when called.
>
> —
> Jenna / @Bluebie
>
> On Thursday, 10 February 2011 at 11:54 AM, Tony Miller wrote:
>
> I want to use the same controller for every javascript file...so I was
> thinking something like this? What I'm not sure of is what to pass to
> File.read.
>
> class Javascript < R '/*.js'
> JS = File.read()
> def get
> @@headers['Content-Type'] = 'text/javascript; charset=utf-8'
> JS
> end
> end
>
> Is there a better way to do this? I was looking at adam's project:
> https://github.com/minikomi/tokyoartparties/blob/master/src/Drinking.rb
> and I didn't see a controller for his css, so I'm kind of wondering
> how he does it...
>
> Thanks,
> -Tony
> _______________________________________________
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
>
> _______________________________________________
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to