RSRuby installation and R configuration error - ruby-on-rails

I tried to install RSRuby following the steps mentioned in http://web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/manual.pdf and http://nsaunders.wordpress.com/2009/05/20/baby-steps-with-rsruby-in-rails/ and I must say that nsaunders blog is indeed a great start for anyone installing RSRuby. But when I tried to check from the irb by creating an instance of RSRuby:
r = RSRuby.instance
it returned me error:
1.8.7-p371 :001 > r = RSRuby.instance
NameError: uninitialized constant RSRuby
from (irb):1
I have all the prerequisites: R_HOME, shared lib option and other stuff. I dont know why I got this error. Any ideas guyzz?????
has anyone tried it for rails successfully???

Without seeing the full source code it's difficult to give you an answer, so this is just a guess. Did you remember to require 'rsruby' within your code? NameError is often caused when a gem is installed but the code does not include the appropriate require statement:
require 'rsruby'
r = RSRuby.instance
You can see this in the code example in the "Documentation" section of the README in the GitHub project.

Related

Ruby gem origami sign signature failed

I'm trying to make the PDF file with signature with origami gem, follow this example https://github.com/gdelugre/origami/blob/master/examples/signature/signature.rb
Now i just run this signature.rb and got error
[error] Breaking on: ">>\nendobj\n..." at offset 0x1f6f3
[error] Last exception: [Origami::InvalidObjectError] Failed to parse object (no:43,gen:0) -> [ArgumentError] wrong number of arguments (given 1, expected 0; required keyword: year)
I have no idea to move forward :'<
I also found the sign method of gem at https://github.com/gdelugre/origami/blob/master/lib/origami/signature.rb, and have take a look, I can't find any specific things to do :'<
Might this example is outdate?
The error message is known see https://github.com/gdelugre/origami/issues/80
A fix should be available https://github.com/gdelugre/origami/pull/74/commits
But has not been added so use newer file from the fork https://github.com/pocke/origami/tree/fix-ruby-2.7-kwargs-warnings
Specifically you need this updated file and may need to follow any other suggestions from above.
https://github.com/pocke/origami/raw/fix-ruby-2.7-kwargs-warnings/lib/origami/filters/predictors.rb
However it always worth looking for a fork with many more recent improvements such as
https://github.com/joelsondrew/origami

Ruby uninitialized constant Pipl::Person (NameError)

I am trying to integrate the Pipl API into my ruby on rails application. I am using ruby version 2.3.4 and rails 4.2.5. As a reference i looked at
this site
and copied the ruby version of the code directly from it into a ruby file. When I run the ruby file in the terminal i get the error:
`<main>': uninitialized constant Pipl::Person (NameError)
Any ideas why I'm getting this error? Any help is greatly appreciated.
This is the code snippet that I used:
require 'pipl'
person = Pipl::Person.new
person.add_field Pipl::Name.new(first: 'Clark', last: 'Kent')
person.add_field Pipl::Address.new(country: 'US', state: 'KS', city:
'Smallville')
person.add_field Pipl::Address.new(country: 'US', state: 'KS', city:
'Metropolis')
response = Pipl::client.search person: person, api_key: 'myKEY' #I used my actual key here
puts "#{response}"
Thanks!
In order to use the Pipl API without the error, I got my API key through their site and I added piplapis-ruby gem just like what was told in the comments above. I imported all of the ruby classes found here: https://github.com/piplcom/piplapis-ruby into my project and pasted the codesnippet.rb file found here: https://github.com/piplcom/piplapis-ruby which was the ruby file you're supposed to execute. There was no need for me to create the Person class.

Rails 5: Error when removed quiet_assets_path from development.rb

I have been trying to upgrade my app from Rails 4 to Rails 5. In my Rails 4 version I have quiet_assets_path set but in Rails 5 it is not required. But when I removed that tried to start the server I am getting the following error,
> ruby-2.2.2/gems/rack-mini-profiler-0.10.2/lib/mini_profiler_rails/railtie.rb:93:in
> `>': comparison of Fixnum with nil failed (ArgumentError) from
> /Users/Admin/.rvm/gems/ruby-2.2.2/gems/rack-mini-profiler-0.10.2/lib/mini_profiler_rails/railtie.rb:93:in
> `block in <class:Railtie>'
Can someone help me with this?
Edit:
Following is my rack_profiler.rb,
if Rails.env.development? || Rails.env.production?
require 'rack-mini-profiler'
# initialization is skipped so trigger it
Rack::MiniProfilerRails.initialize!(Rails.application)
Rack::MiniProfiler.config.skip_schema_queries = true
Rack::MiniProfiler.config.skip_paths += %w(/admin/sidekiq)
Rails.application.middleware.delete(Rack::MiniProfiler)
Rails.application.middleware.insert_after(Rack::Deflater, Rack::MiniProfiler)
end
When I comment the delete line then server is starting but if the line uncommented then the server breaks.
thanks for the update. First of all, do you use Rack::Deflater middleware in development environment too?
I think this issue might help you. It basically says that in Rails all delete middleware operations are issued at the end. You can use the swap method as described in the above issue.
If you search the repo issues for "Deflater" you'll find a lot of results, but I believe the above contains your fix.

Activesupport / Multi json: "Did not recognize your adapter specification"

I have a Ruby 1.9.3 / Rails 3.1 project with the following in the gemfile:
gem 'rails', '3.1.12'
gem 'json'
gem 'multi_json', '1.7.7'
That version of rails sets activesupport to 3.1.12 as well. I'm not sure what the exact cause of the problem is, but when running bundle exec rake test, I got the error:
/home/user/.gem/ruby/1.9.3/gems/multi_json-1.7.7/lib/multi_json.rb:121:in 'rescue in load_adapter': Did not recognize your adapter specification. (ArgumentError)
...
(more stack trace, including activesupport methods)
Fortunately I found a solution! See below.
Edit: My original answer is outdated and incorrect; read it if you please, but please read the updated information at the bottom.
After viewing a ton of other questions such as these ones:
OmniAuth Login With Twitter - "Did not recognize your adapter specification." Error
Capistrano deploy: "Did not recognize your adapter specification" during assets:precompile
https://github.com/intridea/multi_json/issues/132
I hadn't found a solution, so I dove into the library and determined that load_adapter was receiving the parameter "JSONGem". The alias was failing, and the method attempted to load
/home/user/.gem/ruby/1.9.3/gems/multi_json-1.7.7/lib/multi_json/adapters/JSONGem.rb
This file doesn't exist, but .../json_gem.rb does exist! So I modified load adapter as follows:
def load_adapter(new_adapter)
# puts "new_adapter: #{new_adapter}" # Debugging
# puts "new_adapater.class: #{new_adapter.class}" # Debugging
case new_adapter
when String, Symbol
new_adapter = ALIASES.fetch(new_adapter.to_s, new_adapter)
new_adapter = "json_gem" if new_adapter =~ /^jsongem$/i # I added this line
# puts "final adapter: #{new_adapter}" # debugging
require "multi_json/adapters/#{new_adapter}"
klass_name = new_adapter.to_s.split('_').map(&:capitalize) * ''
MultiJson::Adapters.const_get(klass_name)
when NilClass, FalseClass
load_adapter default_adapter
when Class, Module
new_adapter
else
raise NameError
end
rescue NameError, ::LoadError
raise ArgumentError, 'Did not recognize your adapter specification.'
end
This fixed the problem for me. It's probably not an optimal solution (ideally I would understand WHY the ALIASES.fetch failed, if that is indeed what happened, and fix that), but if your problem is similar then hopefully this quick fix can help.
Update
It's not viable for deployability reasons to modify someone else's gem. Fortunately I found the root cause of the problem. In project_root/config/initializers/security_patches.rb, we had the line
ActiveSupport::JSON.backend = "JSONGem"
This was the recommended fix to a security bug in older versions of rails. Now that we are on a newer version of rails (i.e, > 3.0), we can simply replace "JSONGem" with "json_gem" (which is what my original modification was doing, in a roundabout way) and not worry about the security issue.

uninitialized constant ShopifyAPI::CustomerGroup::Customers error

No doubt I am doing something wrong here, but I am following instructions on a new commit from here.
I am getting the following error
uninitialized constant ShopifyAPI::CustomerGroup::Customers
00:33:56 web.1 | /Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/shopify_api-3.0.3/lib/shopify_api/resources/customer_group.rb:4:in `customers''
When running this code
group = ShopifyAPI::CustomerGroup.find(5614012)
customers = group.customers
Here is the gem file mentioned above
Version 3.0.3 should solve the problem, I'll have to look into why it isn't.
In the meantime, the following will do what you want:
group = ShopfiyAPI::CustomerGroup.find(123)
customers = group.get(:customers)

Resources