Hi,
As I can initialize and add to a bidimensional Array?
I am mirnado in api and I do not see anything it clear.
I am proving thus, but it gives error me:
$itemlist = [][]
$itemlist <<
Item.new(''name1'',''value1'')
Thank you very much.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
You don''t need to declare it as bidirectional. Something like this may
be what your looking for, if not supplying a little more information
would help:
$itemlist = []
$itemlist[0] <<
Item.new(''name1'',''value1'')
This is assuming that Item.new returns an array, that would leave you
with a multi-dimensional array.
Davicín .. wrote:> Hi,
>
> As I can initialize and add to a bidimensional Array?
> I am mirnado in api and I do not see anything it clear.
>
> I am proving thus, but it gives error me:
>
> $itemlist = [][]
> $itemlist <<
Item.new(''name1'',''value1'')
>
>
> Thank you very much.
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks William.
With $itemlist = [] does not work either. :(
My total code is this:
require "uri"
class EstablishmentTypeTemplatesController < ApplicationController
def enviaListaItem
sRedirect = "/establishment_contents/list?"
@params[''item''].each_pair {|key, value|
sRedirect << key << "=" << value <<
"&"
}
enc_url = URI.encode(sRedirect)
redirect_to enc_url
end
def select
if !(params[:addLista]) then
$itemlist = []
$itemlist << Item.new(''Sobre el
Bar'',''1'')
$itemlist << Item.new(''Dónde
Estamos'',''1'')
$itemlist <<
Item.new(''Contactar'',''1'')
end
end
def addItem
if (params[:nombreItem]) then
$itemlist << Item.new(params[:nombreItem],''1'')
render :action => ''select'', :templateID =>
params[:templateID]
end
end
end
And this it is the error that it gives:
ArgumentError in Establishment type templatesController#select
wrong number of arguments (2 for 1)
RAILS_ROOT: ./script/../config/..
#{RAILS_ROOT}/app/controllers/establishment_type_templates_controller.rb:24:in
`initialize''
#{RAILS_ROOT}/app/controllers/establishment_type_templates_controller.rb:24:in
`new''
#{RAILS_ROOT}/app/controllers/establishment_type_templates_controller.rb:24:in
`select''
Request
Parameters: {"templateID"=>"3"}
Show session dump
---
:current_user: "1"
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
Thanks again.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Looks like the constructor for your Item class only takes one argument. What is Item ? (and do you really want a global variable? that will fall over as soon as you have more than one mongrel or more than one user). Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, it appears that there''s an issue with the select method. Could you post it here? Thanks, -Conrad On 9/29/07, Davicín .. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Thanks William. > With $itemlist = [] does not work either. :( > > My total code is this: > > require "uri" > class EstablishmentTypeTemplatesController < ApplicationController > def enviaListaItem > sRedirect = "/establishment_contents/list?" > @params[''item''].each_pair {|key, value| > sRedirect << key << "=" << value << "&" > } > enc_url = URI.encode(sRedirect) > redirect_to enc_url > end > def select > if !(params[:addLista]) then > $itemlist = [] > $itemlist << Item.new(''Sobre el Bar'',''1'') > $itemlist << Item.new(''Dónde Estamos'',''1'') > $itemlist << Item.new(''Contactar'',''1'') > end > end > def addItem > if (params[:nombreItem]) then > $itemlist << Item.new(params[:nombreItem],''1'') > render :action => ''select'', :templateID => params[:templateID] > end > end > end > > And this it is the error that it gives: > > > ArgumentError in Establishment type templatesController#select > wrong number of arguments (2 for 1) > RAILS_ROOT: ./script/../config/.. > > #{RAILS_ROOT}/app/controllers/establishment_type_templates > _controller.rb:24:in > `initialize'' > #{RAILS_ROOT}/app/controllers/establishment_type_templates > _controller.rb:24:in > `new'' > #{RAILS_ROOT}/app/controllers/establishment_type_templates > _controller.rb:24:in > `select'' > > Request > Parameters: {"templateID"=>"3"} > > Show session dump > > --- > :current_user: "1" > flash: !map:ActionController::Flash::FlashHash {} > > > Response > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} > > Thanks again. > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def select
if !(params[:addLista]) then
$itemlist = []
$itemlist << Item.new(''Sobre el
Bar'',''1'')
$itemlist << Item.new(''Dónde
Estamos'',''1'')
$itemlist <<
Item.new(''Contactar'',''1'')
end
end
Item.new(''Sobre el Bar'',''1'') are trouble
(ArgumentError)
You should do:
Item.new(:name => ''Sobre el Bar'',
:number=>''1'')
mean you need describe methods/field names by your model Item.
http://www.yulia-site.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
def select
if !(params[:addLista]) then
$itemlist = []
$itemlist << Item.new(''Sobre el
Bar'',''1'')
$itemlist << Item.new(''Dónde
Estamos'',''1'')
$itemlist <<
Item.new(''Contactar'',''1'')
end
end
Item.new(''Sobre el Bar'',''1'') are trouble
(ArgumentError)
You should do:
Item.new(:name => ''Sobre el Bar'',
:number=>''1'')
mean you need describe methods/field names by your model Item.
/offtop
donate to Yulia: http://www.yulia-site.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
alexey.Creopolis wrote:> def select > if !(params[:addLista]) then > $itemlist = [] > $itemlist << Item.new(''Sobre el Bar'',''1'') > $itemlist << Item.new(''D�nde Estamos'',''1'') > $itemlist << Item.new(''Contactar'',''1'') > end > end > > Item.new(''Sobre el Bar'',''1'') are trouble (ArgumentError) > You should do: > Item.new(:name => ''Sobre el Bar'', :number=>''1'') > mean you need describe methods/field names by your model Item. > > > /offtop > donate to Yulia: http://www.yulia-site.orgThanks to all. My problem was as you said, that it thought that to add to a list it was necessary to make a New of a variable. Now I have it thus and it works to me def select if !(params[:addLista]) then $itemlist = [[''Sobre el Bar'',''1''], [''Dónde Estamos'',''1''], [''Contactar'',''1'']] end end [...] $itemlist << [params[:nombreItem],''1''] Thank you very much. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---