Displaying 20 results from an estimated 37 matches for "symbolize_keys".
2006 May 14
0
Beware of HashWithIndifferentAccess#symbolize_keys!
Hi,
I just posted a patch tot he rails trac for a bug we found where
running symbolize_keys! on a HashWithIndifferentAccess will delete all
items from the hash. Please make sure you either never call
symbolize_keys! (or to_options! which just alias it) on a
HashWithIndifferentAccess, or apply the path attached from the ticket
at: http://dev.rubyonrails.org/ticket/5076
I also posted a muc...
2007 Apr 18
3
nil.symbolize_keys -- error with attachment_fu
...er then the
error goes away. This same error is also happening on the create
method, even though it is the exact same code on my local machine.
Here is the error:
NoMethodError in UsersController#new
You have a nil object when you didn''t expect it!
The error occurred while evaluating nil.symbolize_keys
#{RAILS_ROOT}/vendor/plugins/attachment_fu/lib/technoweenie/
attachment_fu/backends/s3_backend.rb:136:in `included''
#{RAILS_ROOT}/vendor/plugins/attachment_fu/lib/technoweenie/
attachment_fu.rb:79:in `include''
#{RAILS_ROOT}/vendor/plugins/attachment_fu/lib/technoweenie/
attachmen...
2008 Jan 18
2
NameError when using alias_method -- but method exists?
...#39;' method in the
YAML module. Following along with the PickAxe example of making old
methods do new things, I try this in irb:
>> module YAML
>> alias_method :orig_load_f, :load_file
>> def load_file(*args)
>> contents = orig_load_f(*args)
>> contents.symbolize_keys.each_value {|v| v.symbolize_keys }
>> end
>> end
But after that last ''end'', irb explodes, saying:
NameError: undefined method `load_file'' for module `YAML''
from (irb):2:in `alias_method''
from (irb):2
But, continuing in ir...
2009 Aug 07
2
paperclip model fails while when updating with no attachment
..._save create_or_update_assets!
def create_or_update_assets!
# return if there are no asset_attributes
return true if asset_attributes.nil? || asset_attributes.empty?
# pull the attributes from the instance variable
asset_attributes.each do |attributes_hash|
attributes_hash.symbolize_keys!
# if atts_hash has an id (asset already exists). If there''s no id
then this is a new asset.
asset = attributes_hash[:id].blank? ? assets.build : assets.detect
{ |product| product.id == attributes_hash[:id].to_i }
asset.attachment = attributes_hash[:attachment] # adds t...
2008 Apr 19
3
How to find nil object error in the rails application?
After I added some plugins to rails my application it begin to give
following error.
Error during failsafe response: You have a nil object when you didn''t
expect it!
The error occurred while evaluating nil.symbolize_keys
(originally You have a nil object when you didn''t expect it!
The error occurred while evaluating nil.symbolize_keys)
But there is no stack trace I dont know why?
When I searched in the code symbolize_keys is used in lot of places. So
I dont understand which one is error reason.
Coul...
2006 Aug 13
1
establish_connection method
...ions[name] = spec
when Symbol, String
if configuration = configurations[spec.to_s]
establish_connection(configuration)
else
raise AdapterNotSpecified, "#{spec} database is not
configured"
end
else
spec = spec.symbolize_keys
unless spec.key?(:adapter) then raise AdapterNotSpecified,
"database configuration does not specify adapter" end
adapter_method = "#{spec[:adapter]}_connection"
unless respond_to?(adapter_method) then raise AdapterNotFound,
"database configur...
2005 Mar 15
0
0.10.0, Routes and Query strings
...in_controller/index
But when I add a query string to the end like this...
http://www.siteroot.com/?offset=10
...the poop hits the fan
And I get this stacktrace in my error.log
/Library/WebServer/sidewayspony/public/../config/..//vendor/activesupport/lib/active_support/core_ext/hash/keys.rb:27:in
`symbolize_keys'': undefined method `to_sym'' for nil:NilClass
(NoMethodError)
from /Library/WebServer/sidewayspony/public/../config/..//vendor/activesupport/lib/active_support/core_ext/hash/keys.rb:26:in
`inject''
from /Library/WebServer/sidewayspony/public/../config/..//ve...
2007 Sep 18
0
Help with RESTful named url options
...d:''get''});
return false;">Show Detail</a>
Instead I get:
You have a nil object when you didn''t expect it!
The error occurred while evaluating nil.to_sym
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/hash/keys.rb:27:in `symbolize_keys''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/
base.rb:518:in `inject''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/hash/keys.rb:26:in `symbolize_keys''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/act...
2010 Feb 22
0
Re: rake db:migrate throws unexpected error
danwoods wrote:
> The Error:
> (in [my current directory])
> rake aborted!
> undefined method `symbolize_keys'' for nil:NilClass
Given that nil does not implement symbolize_keys you need to know where
you''re ending up with a nil.
Have your run your rake task with the --trace option to see if you get a
backtrace that will show you where to look?
rake --trace db:migrate RAILS_ENV=stagin...
2006 May 05
3
posting xml in functional test
Hello,
I''m trying to write a functional test for a simple CRUD controller which
accepts / emits xml in a REST- like fashion. However the following code
won''t work for me - an exception is generated
def test_create
post :create, ''<person><name>john</name></person>'',
2006 Apr 16
3
variable variables?
Hi everyone,
Does Ruby support variable variables like PHP
(http://www.php.net/manual/en/language.variables.variable.php)? Or do I have
to use eval, like
some_hash.each_pair{|key, pair|
eval "#{key} = #{value}"
}
Or is there some other way?
I''m actually trying to figure this out in order to use ez_where to create
its conditions from a hash, so if this isn''t even
2005 May 04
1
Conditional validations
...ActiveRecord::Validations
would be very simple. In the validates_each method, I added the
following line:
if options[:if] and record.send(options[:if])
... so that validates_each now looks like this:
def validates_each(*attrs)
options = attrs.last.is_a?(Hash) ? attrs.pop.symbolize_keys : {}
attrs = attrs.flatten
# Declare the validation.
send(validation_method(options[:on] || :save)) do |record|
if options[:if] and record.send(options[:if])
attrs.each do |attr|
value = record.send(attr)
next if value.nil?...
2008 Jan 31
3
presenting validation errors via fbml?
Hi Facebookers,
Is there a helper or suggested approach for presenting validation
errors on an fbml form?
Something to translate rails error markup to fbml:error markup?
thanks
Joel
2007 Oct 04
1
PUT- or POST-ing xml
...ework, as far as I can tell, so it suffers the same result; it tries to
symbolize the keys of the ''parameters'' hash, except the parameters aren''t a
hash:
1)
> NoMethodError in ''Assign Roles to Users should assign a single role''
> undefined method `symbolize_keys'' for #<String:0xb722d71c>
> /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/test_process.rb:101:in
> `assign_parameters''
> /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/test_process.rb:377:in
> `process''
> /us...
2006 Jun 13
7
help with ''error_messages_for''
Greetings,
I''m in the throws of deploying an app on site5, and I''m getting strange
errors. I think I might need to understand how error_messages_for
works.
I get a pretty standard looking error:
"
You have a nil object when you didn''t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occured while evaluating nil.errors
Extracted
2006 Nov 04
6
image_tag keeping add ???? after the url it generates
...ot;
I''ve checked the source code of image_tag, and couldn''t find any solution.
The ????
is appended to the "source" parameter before it goes to the real image_tag
code.
def image_tag(source, options = {})
puts source # already ????? here
options.symbolize_keys!
options[:src] = image_path(source)
options[:alt] ||= File.basename(options[:src],
''.*'').split(''.'').first.capitalize
if options[:size]
options[:width], options[:height] = options[:size].split("x")
options.de...
2006 May 08
1
script/generate scaffold errors
...9;m following the Agile Development With Rails book and having some
trouble. Specifically, I''ve typed:
% ruby script/generate scaffold Product Admin
and received the following error:
/usr/local//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/hash/keys.rb:27:in
`symbolize_keys'': undefined method `to_sym'' for
#<YAML::Syck::MergeKey:0x23b2e48> (NoMethodError)
I''ve got rail 1.1.2 and have done
% sudo gem update rails --include-dependencies
and been told that all is up to date. I''m on OSX 10.4.6 and I''m aware
this can b...
2007 Jul 15
0
errors_for
..._helper.rb, I add the error_messages_for method. This
is taken from rails and stripped of some of its pieces like
content_tag and pluralize. I''m sure more of it could be cleaned up if
you wanted to.
def error_messages_for(*params)
options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {}
objects = params.collect {|object_name|
instance_variable_get("@#{object_name}") }.compact
count = objects.inject(0) {|sum, object| sum + object.errors.count }
unless count.zero?
html = {}
[:id, :class].each do |key|
if options.include?(k...
2007 Mar 09
0
link_to_remote with onmouseover event
...ptions = {})
link_to_function_mover(name, remote_function(options),
html_options)
end
def link_to_function_mover(name, *args, &block)
html_options = args.last.is_a?(Hash) ? args.pop : {}
function = args[0] || ''''
html_options.symbolize_keys!
function = update_page(&block) if block_given?
content_tag(
"a", name,
html_options.merge({
:href => html_options[:href] || "javascript:void(0)",
:mouseover => (html_options[:onmouseover] ? "#
{ht...
2006 Dec 20
0
undefined method `to_sym' for #<YAML::Syck::MergeKey...
...ls install. I get something like this when I
try to use script/generate, rake migrate or script/console and probably
others.
0 wicked www/sharkwatch % ./script/console
Loading development environment.
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/hash/keys.rb:27:in
`symbolize_keys'':NoMethodError: undefined method `to_sym'' for
#<YAML::Syck::MergeKey:0xb71dfa6c>
to_sym is indeed *not* defined in /usr/lib/ruby/1.8/yaml.rb or
/usr/lib/ruby/1.8/yaml/*
What''s going on here?
Thanks,
--Dean
--~--~---------~--~----~------------~-------~--~----~...