NameError (uninitialized constant Views::Setup::User):
app/views/setup/user.html.rb:1:in `_app_views_setup_user_html_rb___557294190_11042'
actionpack (3.1.12) lib/action_view/template.rb:144:in `render'
activesupport (3.1.12) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.12) lib/action_view/template.rb:142:in `render'
actionpack (3.1.12) lib/action_view/renderer/template_renderer.rb:40:in `render_template'
actionpack (3.1.12) lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
activesupport (3.1.12) lib/active_support/notifications.rb:53:in `instrument'
activesupport (3.1.12) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.12) lib/active_support/notifications.rb:53:in `instrument'
...
parameters: {"controller"=>"setup", "action"=>"user"}
It appears as though, when running in development mode, the first pageload of a given page will succeed, then the second pageload will throw this uninitialized constant error, referencing the file where the constant (class) is defined...
Was working fine before in Rails 3.0.
Rails 3.1.12
JRuby 1.7.11
Erector 0.10.0
Appears to have been an issue between Rails 3.1 and the Erector gem.
For some reason or another, views named in the scheme "view_name.html.rb" aren't loaded properly after the first load. The same file named "view_name.rb" works fine.
This appears to no longer be the case upon bumping to Rails 3.2, so I assume it's a quirk in 3.1 not properly checking mime types when autoloading.
Related
Started getting loads of these errors today:
F, [2018-08-03T18:02:08.783602 #22987] FATAL -- :
ActionController::InvalidCrossOriginRequest (Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-
origin JavaScript embedding.):
actionpack (4.2.5) lib/action_controller/metal/request_forgery_protection.rb:225:in `verify_same_origin_request'
activesupport (4.2.5) lib/active_support/callbacks.rb:432:in `block in make_lambda'
activesupport (4.2.5) lib/active_support/callbacks.rb:239:in `block in halting'
activesupport (4.2.5) lib/active_support/callbacks.rb:506:in `block in call'
activesupport (4.2.5) lib/active_support/callbacks.rb:506:in `each'
activesupport (4.2.5) lib/active_support/callbacks.rb:506:in `call'
activesupport (4.2.5) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.5) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
....
I never saw this before. The only thing that changed in my application today: I set up a controller behind a generic route to catch routing errors that kept popping up in the prod log due to tons of lame script kiddies probing my sites, it was so annoying that I now just block every IP behind a routing error no questions asked.
I wouldn't care much about this but sometimes some very specific morons try to scrape my sites stealing my stuff so I'm mainly concerned about them coming up with something new, which would also mean I've slightly underestimated the size of their brains.
And now I am getting this error but I have no idea who tries to load what, where from, nothing relevant in the web server logs; how can I figure out what's going on?
When I sign up or sign in using devise. I get following error:
undefined method `flash' for #<ActionDispatch::Request:0xda424ac>
This is my first project using rails 4.2, all previous projects had atmost rails 4.1.8 and I never had similar issue.
Error trace path is:
.../.rvmruby (2.1.2) bundler/gems/devise-2f0002a449a8/lib/devise/failure_app.rb:18:in `flash'
.../.rvmruby (2.1.2) bundler/gems/devise-2f0002a449a8/lib/devise/failure_app.rb:58:in `redirect'
.../.rvmruby (2.1.2) bundler/gems/devise-2f0002a449a8/lib/devise/failure_app.rb:39:in `respond'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
If you need any more information please say, I am stuck with this for some time.
I have seen people having issues using rails-api gem, but I am not using rails-api gem.
Thanks for all your help.
Try adding to your config/application.rb:
config.middleware.use ActionDispatch::Flash
Can't find any resource that's helped me in this! When I try to 'rails s' and go to any page of the app; it shoots me this error page saying I am missing helper files.
I think it's local on my desktop machine because I recently did some work to the app on my laptop. I pushed from the laptop and app works fine on Heroku and runs local on that machine with zero problems. I added a feature to upload company logo images using Carrierwave, Mini_Magick, and Fog to Amazon S3.
Things I've tried so far: I've deleted the app and git clone it back to this machine. I've tried Brew uninstall/install imagemagick and did all the basics like bundle install, rake db:migrate after I cloned the app. Still no luck..
Here is the error codes I am getting on the page and also the full trace:
AbstractController::Helpers::MissingHelperError in PagesController#dashboard
Missing helper file helpers//users/jamesfend/sites/feedbackz/app/helpers/application_helper.rb_helper.rb
Extracted source (around line #1):
1 class ApplicationController < ActionController::Base
2 # Prevent CSRF attacks by raising an exception.
3 # For APIs, you may want to use :null_session instead.
4 protect_from_forgery with: :exception
Full Trace
actionpack (4.2.0) lib/abstract_controller/helpers.rb:151:in `rescue in block in modules_for_helpers'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:148:in `block in modules_for_helpers'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:144:in `map!'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:144:in `modules_for_helpers'
actionpack (4.2.0) lib/action_controller/metal/helpers.rb:93:in `modules_for_helpers'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:108:in `helper'
actionpack (4.2.0) lib/action_controller/railties/helpers.rb:17:in `inherited'
app/controllers/application_controller.rb:1:in `<top (required)>'
activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `load'
activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
app/controllers/pages_controller.rb:1:in `<top (required)>'
activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `load'
activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.2.0) lib/active_support/inflector/methods.rb:261:in `const_get'
activesupport (4.2.0) lib/active_support/inflector/methods.rb:261:in `block in constantize'
activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `constantize'
activesupport (4.2.0) lib/active_support/dependencies.rb:566:in `get'
activesupport (4.2.0) lib/active_support/dependencies.rb:597:in `constantize'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:59:in `controller'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:38:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
/Users/jamesfend/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/jamesfend/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/jamesfend/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Pages Controller
class PagesController < ApplicationController
def dashboard
#title = 'Feedbackz by Amazio Labs'
#header_title = 'Dashboard'
end
def billing
#title = 'Billing & Plans - Feedbackz by Amazio Labs'
#header_title = 'Billing & Plans'
#user = User.find(current_user.id)
end
def contact
#title = 'Contact - Feedbackz by Amazio Labs'
#header_title = 'Contact Us'
end
def faq
#title = 'FAQ - Feedbackz by Amazio Labs'
#header_title = 'Frequently Asked Questions'
end
def invoices
#title = 'Invoices - Feedbackz by Amazio Labs'
#header_title = 'Invoices'
end
def videos
#title = 'Videos - Feedbackz by Amazio Labs'
#header_title = 'Helpful Videos'
end
def schedule
#title = 'Schedule - Feedbackz by Amazio Labs'
#header_title = 'Schedule of Pending Sends'
end
end
This worked for me:
cd ~
mv sites tmpsites
mv tmpsites sites
I also did this, but am unsure if it was required:
cd /
sudo ln -s Users users
Oddly, I can't see the lowercase users symlink, but both ls /users and ls /Users work.
I solved with "spring stop" in the console.
Step-by-Step Guide:
On OSX, I had changed my username to Psy from psy. So figuring the problem out was a pain in the ass. Following these steps helped me out:
Run irb and execute this command in your project folder:
File.expand_path("./")
# => "/Users/psy/code/rails_app"
Now exit irb and run this command in your shell:
$ pwd
# => /Users/Psy/code/rails_app
Compare the two and notice the directory with the case difference, in this case it's Psy
Rename that directory to anything, and then rename it back to the original folder (use sudo only if necessary)
$ sudo mv /Users/Psy /Users/tmp
$ sudo mv /Users/tmp /Users/Psy
While the answer Zubin provided worked for me on my personal machine I just ran into the same issue on a work machine where it didn't exactly. I'd created sites as a lowercase dir:
mkdir sites
Renaming with a capital s fixed it.
mv sites Sites
I found that renaming only the sites folder worked for me just like Zubin pointed out. I did not do the sudo ln command.
mv sites sites1
mv sites1 sites
Simply moving/renaming the folder didn't work for me. I had to rename the existing folder, create a new folder with the same name, then copy everything to it. Then I deleted the old renamed folder.
For me this issue was caused because I was using GitBash on Windows, and running my tests from there. Looks like a case mismatch on what bash is expecting vs the actual folder names. Ran it from cmd and worked fine.
If you are using Windows and Powershell, this issue can occur when running rails s or rails server from a directory which has a certain capitalisation in the filesystem, but if you have changed into the directory in Powershell using a different capitalisation.
For example on my Windows filesystem my rails site is located at:
C:/Code/Personal-Website
however I ran the following commands in powershell to start my server:
C:\Users\XXX XXX> cd C:/code/personal-website
C:\code\personal-website> rails s
This case mismatch between where Powershell thinks it is starting the server versus where the server's document root actually is in the filesystem seems to cause the problem, and ensuring that your Powershell location case matches that of the directories in Windows will stop it.
I get this error while running rails s on windows powershell but not on cmd.
I sugest using a different CLI.
I got the same error as above, but it was not due to a case issue. It ended up being due to a combination of things. I had two ruby version managers installed- rvm and rbenv- and I was using an old gem installer. I had to uninstall rvm (How can I remove RVM (Ruby Version Manager) from my system?) and reinstall rbenv (brew reinstall rbenv)and upgrade to the lastest version of ruby. Then I had to update rubygems (gem update --system). Then, reinstalled all gems and a reboot and everything was fixed.
Essentially, my ruby manager was pointing to an old version of ruby and using an outdated version of the gem installer (2.2.0). You might be able to fix things with just an upgrade to rubygems.
It took me a day and a half to get this resolved. Hopefully, this will save someone some time and frustration.
I started getting the same missing helper message when running tests, even though my app ran OK in dev mode. And this started right after I had run my tests successfully, with no system changes that I was aware of. After trying the suggestion to remove uppercase filenames from my path without success, I ran rvm, in my case
rvm use ruby-2.2.0#rails4.2
bundle install
The problem went away. I suspect my system had rebooted and started using some incompatible system Ruby module. I am a beginner working my way through Michael Hartl's rails tutorial on OS X 10.10.3.
I also encountered this error. All the solutions here didn't work out and I tried different things. Here's my solution which might help others too:
In my project path there was a folder with a vowel mutation / "Umlaut" (ü, ö, ä etc.).
So I changed that and everything worked.
This isn't really a ruby or Rails bug as it is a flaw in OSX (IMHO) resulting from a design decision made many years ago to maintain compatibility with OS 8.0 (classic MacOS) and provide better compatability with Windows FAT/NTFS. That decision was to implement HFS+ with a case preserving but case insensitive naming schema wherein the following paths are equivalent:
/tmp/CASE_insensitive
/tmp/case_INSENSITIVE
You can read more about this in the following quora post:
Why does OS X choose to have a case-insensitive file system instead of a case-sensitive one?
If you've ever configured an HFS+ filesystem to enforce case insensitivity (you know, to be more compatible with actual *nix filesystems) you may very well come across software that just breaks on OSX because that software has been somewhat carelessly written to assume no case insensitivity (IIRC, some Adobe software had great trouble with HFS+ with case sensitivity).
Try this in the OSX terminal:
prompt>mkdir /tmp/CASE_insensitive
prompt>cd /tmp/case_INSENSITIVE
prompt>pwd
/tmp/case_INSENSITIVE
IMHO, that's pretty messed up. Now, if you're using Pow on your OSX system, when you create the symlink in the ~/.pow directory to point to your Rails app, be careful of the case. Mis-typing the case here will result in the error noted by the OP. Simply removing and renaming the symlink with the appropriate case will fix this properly.
I got this error from
rails g controller Name
I just deleted the controller with
rails d controller Name
Then generated it again with lowercase
rails g controller name
I would like to name my controller ESCsController, ESC being the acronym in question. I found the rails inflection docs which describe a way in which to accomplish this.
http://api.rubyonrails.org/classes/ActiveSupport/Inflector/Inflections.html
Note: Acronyms that are passed to pluralize will no longer be recognized, since the acronym will not occur as a delimited unit in the pluralized result. To work around this, you must specify the pluralized form as an acronym as well:
acronym 'API'
camelize(pluralize('api')) #=> 'Apis'
acronym 'APIs'
camelize(pluralize('api')) #=> 'APIs'
I created my controller and models after adding this to environment.rb
ActiveSupport::Inflector.inflections { |i|
i.acronym 'ESC'
i.acronym 'ESCs'
}
Tested in the console these work perfectly. 'ESC'.pluralize() returns ESCs and 'ESCs'.singularize() returns ESC as expected
Controllers and models were generated through rails generate model ESC and rails generate controller ESCs respectively. This created escs_controller.rb and the model esc.rb as expected.
In my routes.rb I used to have
resources :ESCs, path: '/parts/escs'
which returned this error: 'ESCs' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use
I ended up changing it to:
resources :ESCs, controller: 'escs', path: '/parts/escs'
However, now whenever I try and visit a page I get a circular dependency error:
Circular dependency detected while autoloading constant EscsController
Anyone know what's going on? It looks like whatever is trying to load the controller isn't seeing that it should be ESCsController and not EscsController. I'm new to rails so this could be a simple problem...
I'm using Rails 4.0.2
Here's the relevant part of the full stack trace.
activesupport (4.0.2) lib/active_support/dependencies.rb:461:in `load_missing_constant'
activesupport (4.0.2) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.0.2) lib/active_support/inflector/methods.rb:226:in `const_get'
activesupport (4.0.2) lib/active_support/inflector/methods.rb:226:in `block in constantize'
activesupport (4.0.2) lib/active_support/inflector/methods.rb:224:in `each'
activesupport (4.0.2) lib/active_support/inflector/methods.rb:224:in `inject'
activesupport (4.0.2) lib/active_support/inflector/methods.rb:224:in `constantize'
activesupport (4.0.2) lib/active_support/dependencies.rb:535:in `get'
activesupport (4.0.2) lib/active_support/dependencies.rb:566:in `constantize'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:76:in `controller_reference'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:66:in `controller'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:44:in `call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680:in `call'
Try moving code that adds the new inflections from environment.rb to config/initializers/inflections.rb then reload the server. Also, you don't need to specify a controller option for your route, just make it resources :escs, path: '/parts/escs' and it shall work fine.
I use Ruby 1.9.2 and Rails 3.0.5
I have the following error:
incompatible character encodings: ASCII-8BIT and UTF-8
It has nothing to do with the database i think.
The error is happinging on this line in a view (just a div haml call):
#content
full stack:
ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8):
21: -flash.each do |name, msg|
22: =content_tag :div, msg, :id => "flash_#{name}"
23: %div.clear
24: #content
25: = yield
26: = render :partial => "layouts/grid_right" if render_grid_right?
27: = render :partial => "layouts/footer"
app/views/layouts/application.html.haml:24:in `_app_views_layouts_application_html_haml___4380000789490545718_2180251300_2717546578298801795'
actionpack (3.0.5) lib/action_view/template.rb:135:in `block in render'
activesupport (3.0.5) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.5) lib/action_view/template.rb:127:in `render'
actionpack (3.0.5) lib/action_view/render/layouts.rb:80:in `_render_layout'
actionpack (3.0.5) lib/action_view/render/rendering.rb:62:in `block in _render_template'
activesupport (3.0.5) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.5) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.5) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.5) lib/action_view/render/rendering.rb:56:in `_render_template'
actionpack (3.0.5) lib/action_view/render/rendering.rb:26:in `render'
haml (3.0.25) lib/haml/helpers/action_view_mods.rb:13:in `render_with_haml'
actionpack (3.0.5) lib/abstract_controller/rendering.rb:115:in `_render_template'
actionpack (3.0.5) lib/abstract_controller/rendering.rb:109:in `render_to_body'
actionpack (3.0.5) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
actionpack (3.0.5) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
actionpack (3.0.5) lib/abstract_controller/rendering.rb:102:in `render_to_string'
actionpack (3.0.5) lib/abstract_controller/rendering.rb:93:in `render'
actionpack (3.0.5) lib/action_controller/metal/rendering.rb:17:in `render'
actionpack (3.0.5) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.0.5) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/michaelkoper/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
activesupport (3.0.5) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.0.5) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.0.5) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.0.5) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
actionpack (3.0.5) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.0.5) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.0.5) lib/action_controller/metal/mime_responds.rb:261:in `block in retrieve_response_from_mimes'
actionpack (3.0.5) lib/action_controller/metal/mime_responds.rb:192:in `call'
actionpack (3.0.5) lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
app/controllers/home_controller.rb:9:in `index'
actionpack (3.0.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.5) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.5) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.5) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.5) lib/active_support/callbacks.rb:445:in `_run__3968431659371141392__process_action__3163094469870857953__callbacks'
activesupport (3.0.5) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.5) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.5) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.5) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.5) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.5) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.5) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.5) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.5) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.5) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.5) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.5) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.5) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.5) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.5) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.5) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.5) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.5) lib/action_dispatch/routing/route_set.rb:492:in `call'
haml (3.0.25) lib/sass/plugin/rack.rb:41:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.5) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.5) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.5) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.5) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.5) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.5) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.5) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.5) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.5) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.5) lib/rails/application.rb:168:in `call'
railties (3.0.5) lib/rails/application.rb:77:in `method_missing'
railties (3.0.5) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/chunked.rb:15:in `call'
rack (1.2.1) lib/rack/handler/mongrel.rb:67:in `process'
mongrel (1.2.0.pre2) lib/mongrel.rb:165:in `block in process_client'
mongrel (1.2.0.pre2) lib/mongrel.rb:164:in `each'
mongrel (1.2.0.pre2) lib/mongrel.rb:164:in `process_client'
mongrel (1.2.0.pre2) lib/mongrel.rb:291:in `block (2 levels) in run'
My gems:
Using rake (0.8.7)
Using RedCloth (4.2.2)
Using abstract (1.0.0)
Using activesupport (3.0.5)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.5)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.5)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.5)
Using arel (2.0.9)
Using activerecord (3.0.5)
Using activeresource (3.0.5)
Using authlogic (2.1.6)
Using xml-simple (1.0.14)
Using aws-s3 (0.6.2)
Using block_helpers (0.3.3)
Using bundler (1.0.10)
Using diff-lcs (1.1.2)
Using json (1.4.6)
Using gherkin (2.3.4)
Using term-ansicolor (1.0.5)
Using cucumber (0.10.0)
Using cucumber-rails (0.3.2)
Using daemons (1.0.10)
Using database_cleaner (0.6.5)
Using factory_girl (1.3.3)
Using faker (0.9.5)
Using formtastic (1.2.3)
Using gem_plugin (0.2.3)
Using haml (3.0.25)
Using thor (0.14.6)
Using railties (3.0.5)
Using rails (3.0.5)
Using kaminari (0.10.4)
Using mongrel (1.2.0.pre2)
Using mysql2 (0.2.6)
Using nokogiri (1.4.4)
Using paperclip (2.3.8)
Using rspec-core (2.5.1)
Using rspec-expectations (2.5.0)
Using rspec-mocks (2.5.0)
Using rspec (2.5.0)
Using yard (0.6.4)
Using pickle (0.4.4)
Using populator (1.0.0)
Using rspec-rails (2.5.0)
Using webrat (0.7.3)
I solved it by following these steps:
Make sure config.encoding = "utf-8" is in the application.rb file.
Make sure you are using the 'mysql2' gem.
Put # encoding: utf-8 at the top of file containing UTF-8 characters.
Above the <App Name>::Application.initialize! line in the environment.rb file, add following two lines:
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
http://rorguide.blogspot.com/2011/06/incompatible-character-encodings-ascii.html
Try to find the exact line which causing this problem and then enforce UTF8 coding, this solution worked for me.
title.to_s.force_encoding("UTF-8")
I have a suspicion that you either copy/pasted a part of your Haml template into the file, or you're working with a non-Unicode/non-UTF-8 friendly editor.
See if you can recreate that file from the scratch in a UTF-8 friendly editor. There are plenty for any platform and see whether this fixes your problem. Start by erasing the line with #content and retyping it manually.
ASCII-8BIT is Ruby's description for characters above the normal 0-0x7f ASCII character-set, and that are single-byte characters. Typically that would be something like ISO-8859-1, or one of its siblings.
If you can identify which character is causing the problem, then you can tell Ruby 1.9.2 to convert between the character set of that character to UTF-8.
James Grey wrote a series of blogs talking about these sort of problems and how to deal with them. I'd recommend going through them.
incompatible character encodings: ASCII-8BIT and UTF-8
That typically happens because you are trying to concatenate two strings, and one contains characters that do not map to the character-set of the other string. There are characters in ISO-8859-1 that do not have equivalents in UTF-8, and vice-versa and how to handle string joining with those incompatibilities requires the programmer to step in.
you can force UTF8 with force_encoding(Encoding::UTF_8):
Example:
<%= yield.force_encoding(Encoding::UTF_8) %>
For Haml put an encoding hint:
-# coding: UTF-8
on the top left of the Haml page.
I installed gem package mysql2.
gem install mysql2
and then I changed the adapter in mysql2 in database.yml.
The problem was the use of incorrect quotes around the iOS version. Make sure all your quotes are ' and not ‘ or ’.
https://github.com/CocoaPods/CocoaPods/issues/829
For prevent an error "can't modify frozen string" for encoding a varible you can use: var.dup.force_encoding(Encoding::ASCII_8BIT) or var.dup.force_encoding(Encoding::UTF_8)
I've experienced similar problem. Although I had have UTF-8 encodings solved (with mysql2 and Encoding.default_external = Encoding::UTF_8 ...) incompatible character encodings: UTF-8 and ASCII-8BIT arose when I used incorrect helper parameters e.g. f.button :submit, "Zrušiť" - works perfectly but f.button "Zrušiť"- throws encoding error.
I encountered the error while migrating an app from Ruby 1.8.7 to 1.9.3 and it only occured in production. It turned out that I had some leftovers in my Memcache store. The now encoding sensitive Ruby 1.9.3 version of my app tried to mix old ASCII-8BIT values with new UTF-8.
It was as simple as flushing the cache to fix it for me.
I had a similar issue on a custom CoffeeScript file. I solved it by changing the endline encoding from "Unix/Linux" to "Mac OS Classic"
The creation of pdf-documents with the rails-latex-gem lead to a similar problem.
I solved this by modifying layouts/application.pdf.erb to
\begin{document}
<%= yield.force_encoding("UTF-8") %>
\end{document}
it's very strange that I met this problem because I forgot specify the 'type' parameter. e.g.:
add_column :cms_push_msgs, :android_title
which should be:
add_column :cms_push_msgs, :android_content, :string
Just for the record: for me it turned out that it was the gem called 'mysql' ... obviously this is working with US-ASCII 8 bit by default. So changing it to the gem called mysql2 (the 2 is the important point here) solved all of my issues.
I looked # the gem list posted above - Michael Koper has obviously mysql2 installed but I posted this in case someone has this issue as well .. (took me some time to figure out).
If you dislike this answer please comment and I will delete it.
P.S: German umlauts (ä,ö and ü) screwed it out with mysql
I had the same problem when parsing CSV files on Ruby 1.9.2 that were correctly parsed on Ruby 1.8. I found the answer here. When opening the CSV file with Ruby CSV module it is necessary to specify UTF-8 enconding as following:
CSV.foreach("file.txt", encoding: "UTF-8") do |row|
# foo and bar correctly encoded
foo, bar, ... = row
end
i had a similiar problem and the gem string-scrub automagically fixed it for me. https://github.com/hsbt/string-scrub If the given string contains an invalid byte sequence then that invalid byte sequence is replaced with the unicode replacement character (�) and a new string is returned.
I got the same cryptic error message from Rails 4.1, Ruby 2.3.3 in a recent project, stacktrace originating in layout application.html.haml
After a wild goose chase, the culprit was a UTF-8 character which recently had been added to the footer of all pages. For some weird reason the error would only show up intermittently.
Replacing the UTF-8 character with the corresponding HTML escape sequence &#xHHHH; solved the issue.
I hope this saves other people some time in the future..
If the cause of the error is a render block, this works:
<%= (
render "{SOME_TEMPLATE}", some_variable: some_variable
).force_encoding("UTF-8") %>
I have split the lines to show the brackets and the force encoding