In sinatra, I am executing this piece of Code containing values in Hash object:
#posts[0]["attachment"]["media"][0]["href"] # where #posts belongs to Koala::Facebook::API::GraphCollection class
works fine in sinatra application, however, the use of a loop:
#posts.each do |post|
post["attachment"]["media"][0]["href"]
end
raises the following error:
undefined method `[]' for nil:NilClass
The error that it displays when executed on command line is :
> NoMethodError: undefined method `[]' for nil:NilClass from
> (irb):12:in `block in irb_binding' from (irb):11:in `each' from
> (irb):11
What am I missing?
Related
I'm tryimg to install mongodb-community throgh brew, however, I'm getting the following error:
Error: undefined method name' for nil:NilClass Please report this issue: https://docs.brew.sh/Troubleshooting /usr/local/Homebrew/Library/Homebrew/exceptions.rb:275:in block in initialize'
/usr/local/Homebrew/Library/Homebrew/exceptions.rb:274:in map' /usr/local/Homebrew/Library/Homebrew/exceptions.rb:274:in initialize'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:561:in new' /usr/local/Homebrew/Library/Homebrew/formulary.rb:561:in loader_for'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:420:in factory' /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:633:in block in formulae'
/usr/local/Homebrew/Library/Homebrew/cli/parser.rb:629:in map' /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:629:in formulae'
/usr/local/Homebrew/Library/Homebrew/cli/parser.rb:308:in parse' /usr/local/Homebrew/Library/Homebrew/cmd/install.rb:141:in install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in
So I'm trying to run Jazzy to document my code but I'm not getting very far.
This is what happens when i run Jazzy on my Xcode project written in swift(and some functions in # objc). Do i need to prepare the project in any way? I can't find anything about this, but it's my first time using Xcode and jazzy.
Can anyone tell me why it's not able to run properly am i doing something wrong while running the command?
jazzy
Running xcodebuild
Checking xcodebuild -showBuildSettings
Assuming New Build System is used.
Parsing AppDelegate.swift (1/4)
Parsing Card.swift (2/4)
Parsing SceneDelegate.swift (3/4)
Parsing ViewController.swift (4/4)
0% documentation coverage with 0 undocumented symbols
skipped 4 private, fileprivate, or internal symbols (use `--min-acl` to specify a different minimum ACL)
building site
building search index
jam out ♪♫ to your fresh new docs in `docs`
I tried doing jazzy --min-acl but this happens:
jazzy --min-acl
Traceback (most recent call last):
15: from /usr/local/bin/jazzy:23:in `<main>'
14: from /usr/local/bin/jazzy:23:in `load'
13: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/bin/jazzy:15:in `<top (required)>'
12: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:442:in `parse!'
11: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:485:in `parse_command_line'
10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1678:in `parse!'
9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1656:in `permute!'
8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1562:in `order!'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1568:in `parse_in_order'
6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1568:in `catch'
5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/optparse.rb:1582:in `block in parse_in_order'
4: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:54:in `block in attach_to_option_parser'
3: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:35:in `set'
2: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:35:in `instance_exec'
1: from /Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/config.rb:342:in `block in <class:Config>'
/Library/Ruby/Gems/2.6.0/gems/jazzy-0.13.2/lib/jazzy/source_declaration/access_control_level.rb:64:in `from_human_string': cannot initialize AccessControlLevel with '' (RuntimeError)
For the sake of people searching on google, when jazzy reports skipped items and generates 0% of documentation, invoke jazzy in the following way:
jazzy --min-acl <internal|fileprivate|private>
Swift is internal unless you specify the access otherwise.
Here is a link to the github readme discussing this topic: https://github.com/realm/jazzy#controlling-what-is-documented
When running chef-solo with --no-fork option it gives the error
FATAL: NoMethodError: undefined method `size' for nil:NilClass
Does any one know the reason for it . It works fine when --fork option.
I have a migration I am trying to run to generate postgresql schemas using pg_power.
class CreateSchemas < ActiveRecord::Migration
def change
create_schema 'deprecated'
create_schema 'leaf'
create_schema 'mmp'
create_schema 'mmp_static'
create_schema 'nass'
create_schema 'static'
end
end
When I run the migration, I get the following error
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump
rake aborted!
undefined method `[]' for nil:NilClass
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:17:in `block in dump_extensions'
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:15:in `map'
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:15:in `dump_extensions'
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:6:in `header_with_extensions'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/schema_dumper.rb:26:in `dump'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/schema_dumper.rb:21:in `dump'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:244:in `block (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:243:in `open'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:243:in `block (3 levels) in <top (required)>'
I should say I'm using ruby 2.0, rails 4.0, and the rails4 branch of pg_power.
The library was tested with Ruby <= 1.9.3 (you are using 2.0) and ActiveRecord 3.
It was tested with Rails 3.1.x and 3.2.x, Ruby 1.8.7 REE and 1.9.3.
Moreover, there seems to be some incompatibilities with Rails 4.
The library doesn't use public ActiveRecord API but uses monkey patching (alias_method_chain). I won't be surprise if the exception is because the library does not currently work with Rails 4.
In order to fix the issue you should look what changed in the ActiveRecord internals from Rails 3 to Rails 4 and update the corresponding overrides in the Gem. It may be a small or huge effort, depending on the amount of changes.
I encourage you find an alternative and report the issue in the official issue tracker.
When you was trying to run pg_power against rails4, it really didn't work well.
Now, pg_power supports rails4, you must use 2.X.X version.
I'm not a ruby person and i'm working on a project with Ember.js and i'm using Rake pipeline for compile my scripts.
# AssetFile
$: << 'lib'
require 'rake-pipeline-web-filters'
output BUILD
input SRC_DIR do
match '**/*.handlebars' do
handlebars :precompile => true
concat 'templates.js'
end
match '**/*.coffee' do
coffee_script
end
end
output JS_DIR
input BUILD_DIR do
match '*.js' do
concat 'app.js'
end
end
when i execute rakep on the console works fine the first time but the second time i get an const_missing error
c:/Ruby193/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing': uninitialized constant Rake::Pipeline::ManifestEntry::DateTime (NameError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest_entry.rb:9:in `from_hash'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest.rb:24:in `block in read_manifest'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest.rb:23:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/manifest.rb:23:in `read_manifest'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:225:in `last_manifest'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:219:in `create_file_task'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:197:in `block (2 levels) in generate_rake_tasks'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:196:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:196:in `block in generate_rake_tasks'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:194:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:194:in `map'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/filter.rb:194:in `generate_rake_tasks'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:410:in `block in generate_rake_tasks'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:407:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:407:in `generate_rake_tasks'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:333:in `setup'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:308:in `block in invoke'
from <internal:prelude>:10:in `synchronize'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline.rb:305:in `invoke'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:111:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:111:in `block in invoke'
from <internal:prelude>:10:in `synchronize'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/project.rb:110:in `invoke'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/lib/rake-pipeline/cli.rb:19:in `build'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-pipeline-0.7.0/bin/rakep:4:in `<top (required)>'
from c:/Ruby193/bin/rakep:23:in `load'
from c:/Ruby193/bin/rakep:23:in `<main>'
the rakep command works fine when i remove the files manually or let pass time
Note:I am also having problems to sort the files to concatenate
I just hit upon the same problem. I'm using rake-pipeline to minify stylesheets for a static site.
What's happening here is that rake-pipeline is trying to parse a datetime using the DateTime class, but since you're not working on a Ruby project, the class isn't available. I guess because rake-pipeline is mostly used in Ruby projects, nobody noticed that this was a problem at the time. I can see that this problem has been fixed on the master branch, but a new gem version hasn't been released yet.
In the meantime, you can add the following code to your Assetfile (before your input and output), which will delete the tmp directory before your filters run. This is only a temporary fix as it means that your inputs will be filtered every time, regardless of whether they've changed, but it does negate the need for any dodgy datetime parsing.
require 'fileutils'
FileUtils.rm_rf 'tmp'
Be careful with rm_rf! Make sure it's pointing at your tmp directory and nothing else.
Re: sorting your files, I don't know the specifics of your problem, but you might find this example helpful.