Forum: Ruby on Rails params[:some_data] ||= [] #what does that mean?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
mixplate (Guest)
on 2007-02-06 01:44
is that saying

if params[:some_data] contains something not equal to nil, continue to
the next line of code...else make params[:some_data] into an empty
array?


i tried searching for ||= but no luck.


thanks for any help!
Anton Aylward (Guest)
on 2007-02-06 01:56
(Received via mailing list)
While on that question...

Is there any reason I can set up config/routes.rb to had all of the URL
except for the domain, no matter how many slashes or named parameters,
to
one 'FigureOutTheUrl' controller?

In that case, how do I deal with a variable number of slashes in the
URL?


--
We'll give you your money back if not satisfied, but we do suspect that
we will be quite satisfied with your money.
mixplate (Guest)
on 2007-02-06 02:01

what reason are you looking for? why do such a thing?

Anton Aylward wrote:
> While on that question...
>
> Is there any reason I can set up config/routes.rb to had all of the URL
> except for the domain, no matter how many slashes or named parameters,
> to
> one 'FigureOutTheUrl' controller?
>
> In that case, how do I deal with a variable number of slashes in the
> URL?
>
>
> --
> We'll give you your money back if not satisfied, but we do suspect that
> we will be quite satisfied with your money.
jdswift (Guest)
on 2007-02-06 02:20
(Received via mailing list)
On Feb 6, 10:44 am, mixplate <rails-mailing-l...@andreas-s.net> wrote:
> --
> Posted viahttp://www.ruby-forum.com/.

Yes, it initiates params[:some_data] as an array if it is null.
Ben Munat (Guest)
on 2007-02-06 02:22
(Received via mailing list)
Yep, that's what ||= means... and yes it is very difficult to search the
web for symbolic stuff like that. If you have the Agile Rails book in
pdf form however, you can search for that expression sucessfully.

b
Anton Aylward (Guest)
on 2007-02-06 02:26
(Received via mailing list)
One step beyond' tressle'.

A wiki with the syntax can be

      /web/topic

No "controller", no "action".
Defaults to "show"
I would think that is what most users might expect.

Only when you need to edit

  /web/topic?edit

Some wiki have a topic that is the index page, like TWiki,
so
  /web/index
is a case of
        /web/topic
and not
  /web action => 'index'
Which means you can write different styles of index pages - not need to
hack
the code.  isn't that what a wiki is about?

mixplate said the following on 02/05/2007 08:01 PM:
>> one 'FigureOutTheUrl' controller?
>>
>> In that case, how do I deal with a variable number of slashes in the
>> URL?
>>
>>
>> --
>> We'll give you your money back if not satisfied, but we do suspect that
>> we will be quite satisfied with your money.
>
>

--
Hi! I'm a signature virus! Copy me into your .signature file to help me
spread!
Philip Hallstrom (Guest)
on 2007-02-06 02:30
(Received via mailing list)
> While on that question...
>
> Is there any reason I can set up config/routes.rb to had all of the URL
> except for the domain, no matter how many slashes or named parameters, to
> one 'FigureOutTheUrl' controller?
>
> In that case, how do I deal with a variable number of slashes in the URL?

Yes, just make sure it is *the* last url in routes.rb

   #
   # Catchall to handle redirects for old site urls
   #
   map.connect "*args", :controller => "url_mapper", :action => "index"


I'd start with a controller action of:

render :text => params.inspect

to see what comes in and then go from there...

-philip
This topic is locked and can not be replied to.