Hi, It''s a little bit annoying to me, I can''t understand the following: If I merge a value to the params hash with: params => params.merge :value => new_value the params[:value] doesn''t change, but if I use string instead of a symbol like: params => params.merge "value" => new_value it works. Somebody plz tell me why... Abbath
I believe that :value and "value" are complety different keys. One is a string, the other is a symbol. On 3/2/06, Abbath <abbath@invitel.hu> wrote:> Hi, > > It''s a little bit annoying to me, I can''t understand the following: > > If I merge a value to the params hash with: > > params => params.merge :value => new_value > > the params[:value] doesn''t change, but if I use string instead of a > symbol like: > > params => params.merge "value" => new_value > > it works. > > Somebody plz tell me why... > > Abbath > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ok, You would be right if the params object had been a Hash. But - as I know - it''s a HashWithIndifferentAccess object in which the symbol and the string key should be the same.> I believe that :value and "value" are complety different keys. One is > a string, the other is a symbol.> On 3/2/06, Abbath <abbath@invitel.hu> wrote: >> Hi, >> >> It''s a little bit annoying to me, I can''t understand the following: >> >> If I merge a value to the params hash with: >> >> params => params.merge :value => new_value >> >> the params[:value] doesn''t change, but if I use string instead of a >> symbol like: >> >> params => params.merge "value" => new_value >> >> it works. >> >> Somebody plz tell me why... >> >> Abbath >> >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >>
A bit late to the party, but I filed a bug on this some while ago. It''s still in the queue, AFAIK. In the mean while, you can work around it quite simply: class HashWithIndifferentAccess def merge(hash) self.dup.update(hash) end end On 3/7/06, Abbath <abbath@invitel.hu> wrote:> > Ok, You would be right if the params object had been a Hash. But - as > I know - it''s a HashWithIndifferentAccess object in which the symbol > and the string key should be the same. > > > > I believe that :value and "value" are complety different keys. One is > > a string, the other is a symbol. > > > On 3/2/06, Abbath <abbath@invitel.hu> wrote: > >> Hi, > >> > >> It''s a little bit annoying to me, I can''t understand the following: > >> > >> If I merge a value to the params hash with: > >> > >> params => params.merge :value => new_value > >> > >> the params[:value] doesn''t change, but if I use string instead of a > >> symbol like: > >> > >> params => params.merge "value" => new_value > >> > >> it works. > >> > >> Somebody plz tell me why... > >> > >> Abbath > >> > >> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/658353af/attachment-0001.html