rest-open-uri on heroku with ruby 2.0 - ruby-on-rails

Since the default encoding is now utf-8 for Ruby 2.0, the rest-open-uri gem throws the following error on heroku:
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require': /app/vendor/bundle/ruby/2.0.0/gems/rest-open-uri-1.0.0/lib/rest-open-uri.rb:413: invalid multibyte escape: /[\r\n\t !#-[]-~\x80-\xff]+|(\[\x00-\x7f])/ (SyntaxError)
I need to change the following line in rest-open-uri.rb. How can I access this file on heroku?
lib/ruby/gems/2.0.0/gems/rest-open-uri-1.0.0/lib/rest-open-uri.rb
# encoding: US-ASCII

rest-open-uri looks like a dead project. Do you want to get in the business of patching up 8 year old code to get your application to work?
It looks like rf-rest-open-uri is a more up-to-date fork of that project, have you tried it? I don't see any encoding instruction in that gem's rest-open-uri.rb source file.

Related

Rails - ckeditor orm failed to install correctly

So i made a bit of a mistake when trying to add ckeditor to my Rails project last night.
I was following a tutorial and it came to a point in the installation of this gem where it told me to input the following command:
rails generate ckeditor:install --orm=active_record --backend=carrierwave
except i misspelled 'record'
I've looked everywhere i can think and i cant seem to fix this, rails d ... doesnt work gem uninstall doesnt fix it either, and i can't see any related files in my db folder, or anywhere else that i know to look at.
heres the first bit of the error i keep seeing:
/home/naazarik/.rvm/gems/ruby-2.3.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- ckeditor/orm/active_recort (LoadError)
from /home/naazarik/.rvm/gems/ruby-2.3.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
notice the misspelled active_recort?
anyways does anyone have any idea how to either fix this, or remove this from my project?
Thanks!
CKEditor installer should generate config/initializers/ckeditor.rb file that in your case will have following line: require 'ckeditor/orm/active_recort', which you can update to say active_record instead
However, ActiveRecord integration requires a few more files to be generated (and these files were not generated due to a misspelling). Because of that I believe the best way to fix the problem is just to remove the initializer file entirely and run the rails generate ckeditor:install command again.

Rails - Unable to use gem in controller

I am attempting to use the Roo gem to parse a spreadsheet file in my Rails controller. I have added the appropriate line to my Gemfile and ran the bundle command. Here is the line in my controller where everything breaks:
xlsx = Roo::Spreadsheet.open(filepath)
I receive an error: uninitialized constant MyController::Roo. I then added the following line to the top of my controller file (as specified in the Roo readme):
require 'roo'
Now I get a different error: Error during failsafe response: cannot load such file -- roo.
What am I doing wrong?
Did you bundle and restart your server?
Adding gems, modifying app/config files or app/lib files require a server restart :)

Error Parsing 'Gemfile'

I am working on a learning rails project on
http://railsapps.github.io/installrubyonrails-mac.html
I am on the Rails Example Applications section, but when I run
bundle install --without production
I receive this error:
[!] There was an error parsing `Gemfile`: no .<digit> floating literal anymore; put 0 before dot - ruby ‘2.3.0’
^
/Users/eric.park/workspace/learn-rails/Gemfile:2: syntax error, unexpected tFLOAT, expecting '('
ruby ‘2.3.0’
^. Bundler cannot continue.
# from /Users/eric.park/workspace/learn-rails/Gemfile:2
# -------------------------------------------
# source 'https://rubygems.org'
> ruby ‘2.3.0’
# gem 'rails', '4.2.5'
# -------------------------------------------
I am new to rails, so if anyone can explain what this error generally means, and how I can address it if it shows up again that would be really helpful.
It is the quotation problem.
Try manually typing the sentence again with either single quote or double quote.
ruby '2.3.0' or ruby "2.3.0"
This should fix it.
I found that if you copy and pasted code into a Gemfile that you say, created with textedit, unidentified syntax and formatting are also inherent with the copy, and therefore my solution was to open a completely blank document, or write it direct in VIM etc, and type from scratch - do not copy and paste code, otherwise you risk copying over unintentional formatting and imbedded syntax that you might not be able to see.

Rails project won't start - error unexpected : expecting $end

I wanted to get ribbot an open source code from this git repository. I have already downloaded rails and its necessary gems, as well as mongo db and have "bundle installed".
However I get the following error when running the project.
How can this be solved?
/Library/Ruby/Gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load': /Users/hansarijanto/Desktop/Impact/ribbot/config/initializers/session_store.rb:4:
syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_ribbot_session', :domain =>...
I have traced the file with the syntax error which is session_store.rb which currently looks like this:
# Be sure to restart your server when you modify this file.
# See environment specific overrides also
Ribbot::Application.config.session_store :cookie_store, key: '_ribbot_session', :domain => :all, :expire_after => 10.years
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Ribbot::Application.config.session_store :active_record_sto
You're using Ruby 1.8 but are using Ruby 1.9 hash syntax in your config/initializers/session_store.rb. The following snippet:
key: '_ribbot_session'
should be
:key => '_ribbot_session'
since ribbot is using ruby 1.9 you should update your ruby version, rather than change the code to make it work, the current ruby version is 1.9.3
http://www.ruby-lang.org/en/downloads/
install instructions
if you're using mac OS:
http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac
if you're using ubuntu linux:
http://www.rubyinside.com/how-to-install-ruby-1-9-2-and-rails-3-0-on-ubuntu-10-10-4148.html
if you're using windows:
http://rubyinstaller.org/

Smartquotes displayed fine in Rails 2, now a problem in Rails 3

My Rails app is working from a mysql database, and when I switched from Rails 2.8, Ruby 1.8 and the mysql gem over to Rails 3.0.7, Ruby 1.9.2 and the mysql2 gem, all of a sudden my pages are rendering with smartquotes (curly quotes) and em-dashes, etc., all looking like gibberish.
I'm assuming this has something to do with UTF-8, but I don't know how to pinpoint it.
Here's what I do know:
(1) config/database.yml has the following:
development:
adapter: mysql2
encoding: utf8
(2) config/application.rb has the following:
config.encoding = "utf-8"
Don't know where to go from there.
Any suggestions?
You can narrow it down to the db vs the view by doing two things:
rails console # in your terminal in the project directory, then test that your ActiveRecord objects have the correct data.
ViewSource in your browser to see if the generated source is putting in the correct characters.
Later:
This is probably a duplicate of: mysql2 gem, Rails 3.0.3 and "incompatible character encodings" errors https://github.com/brianmario/mysql2/issues/124
And maybe even the monkeypatch here: http://www.rorra.com.ar/2010/07/30/rails-3-mysql-and-utf-8/

Resources