keyongtech


  keyongtech > ruby > 02/2008

 #1  
02-18-08, 08:46 PM
Leslie Viljoen
Hi all!

I have a class that is used in a Webby page. The class needs to make
use of a function within three modules:

--------------------------------------------
module Webby
module Helpers #:nodoc:
module UrlHelper
--------------------------------------------

Since the function is an "instance"
function, I need to include the modules like so:

--------------------------------------------
class Categoriser
include Webby::Helpers::UrlHelper
--------------------------------------------

Later in my class I have (bear with me):

--------------------------------------------
def render
..
html << %[<li> #{link_to_page(:title => r.title)} </li>]
--------------------------------------------

link_to_page (within the three modules) looks like this:

--------------------------------------------
def link_to_page( *args )
self.link_to(*_find_page(args))
end
--------------------------------------------

And gives me:
NoMethodError Exception: undefined method `find' for nil:NilClass

I can't find any reference to this usage of the asterisk, and
I don't know what the *_find_page does. Can anyone explain it to me?


Les
 #2  
02-18-08, 09:05 PM
Jano Svitok
On Feb 18, 2008 9:46 PM, Leslie Viljoen <leslieviljoen> wrote:
[..]
> def link_to_page( *args )
> self.link_to(*_find_page(args))
> end
> --------------------------------------------
>
> And gives me:
> NoMethodError Exception: undefined method `find' for nil:NilClass
>
> I can't find any reference to this usage of the asterisk, and
> I don't know what the *_find_page does. Can anyone explain it to me?


It's called the 'splat' operator.

see e.g.
[url down]
[url down]
http://ola-bini.blogspot.com/2006/11...s-of-ruby.html
 #3  
02-19-08, 08:43 AM
Leslie Viljoen
Thanks! I now know splats!
Similar Threads
Some quastions about Webby

Hello. I want to build my oown simple application based on Webby for making prototypes of web-sies. I plan to use my custom CSS Framework and HAML. How I can change...

webby, ubuntu and gems

I've recently switched distributions to ubuntu, and I'm having problems getting webby up and running. (I suspect this a general problem with gems that need to install...

[ANN] Webby 0.7.2

== Webby by Tim Pease [..] == Description Webby builds websites. It's not a framework. It's not a webserver. It's not a content management system. Webby builds websites...

Webby, Gems and Paths

I am running an Ubuntu box, and it seems that whenever I "gem install" something with an executable (eg. /var/lib/gems/1.8/gems/webby-0.7.2/bin/webby) - I have to make a link...

Upgrade From Asterisk-1.2 To Asterisk-1.4 Via Ports

All, The Asterisk project had just recently released asterisk-1.4 with some new features. However, as of FreeBSD-6.2, the FreeBSD ports still uses asterisk 1.2 and it is in...


All times are GMT. The time now is 04:22 PM. | Privacy Policy