issue with mercury rails gem - ruby-on-rails-3

I was working on a blog app so I want to implemant mercury-rails gem into it, i tried and i got it the tool bar but i was unable to edit any content from my show page
even after everything i am using with the foundation front end framework
<p><span id="page_content class="mercury-region" data-type="editable">
<%=raw #article.content %></span></p>
<h5><span data-type="editable"><%= #article.title %></span></h5>
this is my gem file
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'zurb-foundation'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'simple_form'
gem 'friendly_id'
gem 'devise'
gem "rmagick"
gem "carrierwave"
gem "mercury-rails"

By the looks of things you've followed the old railscast. The mercury-rails projects updates quite frequently.
The problem lies in your attributes on the span tag. You can safely remove the class="mercury-region"
You will also need to change data-type="editable" to data-mercury="full".
See the different edit types (defined in the data-mercury attribute) on the github page: https://github.com/jejacks0n/mercury#region-types
I hope that helps!

Related

What is the correct way to fix bundler not finding compatible versions

I have an old rails 3 application which I want to update to rails 4 at the moment. I removed the Gemfile.lock manually and changed the Gemfile to require rails in version "4.0.0" before running a fresh "bundle install". I was getting several messages that bundler was not able to find compatible versions.
I am using ruby 2.0.0 here installed with rvm on a linux system.
I installed rails 4.0.0 manually using
gem install rails -v 4.0.0
And then I tried again with
bundle install
This is one example of the messages that pop up:
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
activerecord-import (~> 0.4.1) was resolved to 0.4.1, which depends on
activerecord (>= 3.0)
authlogic (~> 3.3.0) was resolved to 3.3.0, which depends on
activerecord (>= 3.2)
delayed_job_active_record (~> 4.0.0) was resolved to 4.0.3, which depends on
activerecord (>= 3.0, < 5.0)
rails (= 4.0.0) was resolved to 4.0.0, which depends on
activerecord (= 4.0.0)
This is my Gemfile:
source 'https://rubygems.org'
# the rails framework: September 14, 2016
gem 'rails', '4.0.0'
# the postgres db connector
gem 'pg', '~> 0.18.0'
# a templating engine for html
gem 'haml', '~> 3.1.7'
# authentication solution
gem 'authlogic', '~> 3.3.0'
# role-based authorization system
gem 'acl9', '~> 0.12.1'
# helper methods for rails 3 models
gem 'dynamic_form', '~> 1.1.4'
# upload management for active record
gem 'paperclip', '~> 4.2.2'
# tag a single model on several contexts
gem 'acts-as-taggable-on', '~> 2.4.1'
# read and write spreadsheet documents
gem 'spreadsheet', '0.9.7'
# active record backend for Delayed::Job
gem 'delayed_job_active_record', '~> 4.0.0'
# wrap ruby scripts executed as deamon
gem 'daemons', '~> 1.1.9'
# writing and deploying cron jobs
gem 'whenever', '~> 0.8.2', require: false
# bulk inserting data using active record
gem 'activerecord-import', '~> 0.4.1'
# named scoples for postgres fulltext search
gem 'pg_search', '~> 0.5.7'
# jQuery and the jQuery-ujs driver for your Rails
gem 'jquery-rails', '~> 3.1.3'
# jQuery UI's JavaScript, CSS, and image files
gem 'jquery-ui-rails', '~> 3.0.1'
# paginated queries with Active Record
gem 'will_paginate', '~> 3.0.5'
# group :production do
# performance management system
# gem 'newrelic_rpm'
# end
# Profiling toolkit
# gem 'rack-mini-profiler', :group => :development
group :test, :development do
# unit testing framework
gem 'test-unit', '~> 2.5.4'
# process manager
gem 'foreman', '~> 0.61.0'
# code profiler
# gem 'ruby-prof'
# bindings for the GNOME Libxml2
gem 'libxml-ruby', '~> 2.4.0'
# wrapper for Linux inotify
gem 'rb-inotify', '~> 0.9.1'
# web server
gem 'thin', '~> 1.5.0'
# gem 'debugger'
gem 'better_errors', '~> 0.3.2'
# retrieve the binding of a method's caller
gem 'binding_of_caller', '~> 0.8.0'
# hosted test coverage service (badge)
gem 'coveralls', '~> 0.8.23', require: false
# gem 'codecov', :require => false, :group => :test
end
group :assets do
# sass adapter
gem 'sass-rails', '~> 3.2.3'
# coffee script adapter
gem 'coffee-rails', '~> 3.2.1'
# call java script code and manipulate java script
# gem 'therubyracer', :platforms => :ruby
# uglifier minifies java script
gem 'uglifier', '~> 2.7.2'
end
group :tools do
# code formatter
gem 'rubocop', require: false
# report vulnerable gems
gem 'gemsurance', '~> 0.9.0'
# handle events on file system modifications
gem 'guard', '~> 1.6.1'
# automatically run your tests on file modification
gem 'guard-test', '~> 0.7.0'
# html parser
gem 'hpricot', '~> 0.8.6'
# ruby parser written in pure ruby
gem 'ruby_parser', '~> 3.1.2'
end
Due to the manual install of rails 4 I have activerecord in version 4.0.0 in my gems available. Why does it come up with that message? From my interpretation of the listed activerecord versions the dependency should be fulfilled with version 4.0.0? It is in the listed range between 3.0 and less than 5.

rails 5.1.4 console in production doesn't find models

I think I got a configuration issue with my rails setup in production.
I've got a puma working fine without any issues (connecting to db, loading models etc) and previously was able to use the console (I've encountered this [bug][https://github.com/rails/rails/issues/19256] but worked around it by filling in the database.yml)
When I try to open the console to perform little operations, none of my model classes are found.
✗ bundle exec rails console production
Running via Spring preloader in process 18313
Loading production environment (Rails 5.1.4)
irb(main):001:0> User.count
NameError: uninitialized constant User
from (irb):1
irb(main):002:0>
Similar questions on SO recommend to run ActiveRecord::Base.subclasses and eventually Rails.application.eager_load!
When I do try to run Rails.application.eager_load! I get uninitializaed constant error
irb(main):005:0> Rails.application.eager_load!
NameError: uninitialized constant ApplicationController
Did you mean? ApplicationCable
from app/controllers/accounts_controller.rb:1:in `<top (required)>'
from (irb):5
So I guess my console is now somehow lost and hasn't loaded the project source correctly.
How can I troubleshoot this situation ?
edit 2018-02-15 : I connected my workstation to the prod environment to use the console. This worked at first, the console was behaving correctly. After a couple times the same issues appeared. After doing spring stop I was able again to user my local workstation to open a console in prod.
Interesting fact : this never happens in dev environment, although spring had an app running in this environment.
It turns out spring is also running in prod, although the spring gem is only in dev group. (see below)
Gemfile
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.4'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'therubyracer', platforms: :ruby
gem 'coffee-rails', '~> 4.2'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
gem 'rails-erd', require: false, group: :development
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'pry'
gem 'pry-byebug'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'devise-i18n'
gem 'cancancan', '~> 2.0'
gem 'rolify'
gem 'redis', '~> 3.2'
group :production do
gem "sidekiq"
gem "sentry-raven"
end
gem 'pg'
gem "paperclip", "~> 5.0.0"
gem 'i18n-country-translations'
gem 'rails-i18n', '~> 5.0.0'
gem 'i18n_alchemy'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
If you deployed through Docker make sure using -ti prefix in running command like:
docker exec -ti 4d318d505e9f rails c production

undefined method `page' for # Kaminari::PaginatableArray

I have been using Kaminari since a while. I use to paginate generic arrays using the following line.
Kaminari.paginate_array([1,2,3]).page(1).per(1)
That use to work before but I noticed that since yesterday this show the error
undefined method `page' for #<Kaminari::PaginatableArray:0x007f8e5d10fde0>
However calling page on ActiveRecord relation is working fine. something like this is working
User.page(1).per(1)
My Gem file
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'pg'
# Ok lets try out the heroku business
gem 'heroku'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-fileupload-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Twitter Boostrap and Upgrade dependencies
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
gem 'cap_bootstrap', github: 'benrs44/cap_bootstrap'
gem 'awesome_print'
group :test, :development do
gem 'rspec-rails', '>= 2.0.1'
gem "capybara-webkit"
gem 'capybara'
gem 'launchy'
gem 'selenium-webdriver'
gem 'shoulda-matchers'
gem 'ci_reporter'
gem "factory_girl_rails", "~> 4.0"
# DRb server RSpec
gem "spork-rails"
# To use debugger
gem 'debugger'
end
group :test do
gem "guard-rspec"
gem 'rb-fsevent', '~> 0.9.1'
gem 'database_cleaner'
gem 'fuubar'
end
#Image Uploader
gem 'carrierwave'
#Image Processor
gem "rmagick"
#Video Processor
gem 'video_info'
gem 'hpricot'
#Authenitcation
gem 'omniauth-facebook', '1.4.0'
#Messaging
gem 'mailboxer', github: 'rralston/mailboxer'
gem 'haml-rails'
gem 'simple_form'
#Gelocation
gem 'geocoder'
#Search
gem 'ransack'
# For easily making nouns possessive
gem 'possessive'
#Pagination
gem "kaminari"
gem 'will_paginate', '~> 3.0'
#Web App Monitoring
gem 'newrelic_rpm'
#FB Style Newsfeeds
gem 'public_activity'
# Heroku CDN Link to AWS
gem "asset_sync"
# Carrier Wave link to AWS S#
gem 'fog', '~> 1.12.1'
gem 'cancan'
# client side validtions
gem 'client_side_validations'
# tagging
gem 'acts-as-taggable-on'
# remote file uploads
gem "remotipart", "~> 1.2.1"
# social sharing
gem 'social-share-button'
gem 'devise', "~> 2.2.3"
gem 'omniauth'
gem 'devise-async'
running bundle show bundle show kaminari gives /Users/***/.rvm/gems/ruby-1.9.3-p448/gems/kaminari-0.14.1
Turned out to be that my colleague has added a configuration file for Kaminari and changed this page function with this line.
config.page_method_name = :kaminari_page
So instead of using Kaminari.paginate_array([1,2,3]).page(1).per(1) I should now use
Kaminari.paginate_array([1,2,3]).kaminari_page(1).per(1)

Rails 3 Coffee Handler Missing

Im using Ruby 1.9.3p0, Rails 3.1.2 with Apache and Passenger in Production. When I try to make a remote function, it throws me this error:
ActionView::MissingTemplate (Missing template video/loadVideo, application/loadVideo with
{:handlers=>[:erb, :builder], :formats=>[:js, "application/ecmascript", "application/x-
ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml,
:multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}. Searched in
As you can see, there is no handler for :coffee, that's the reason why is not processing the file video/loadVideo.js.coffee; I run the command rake assets:precompile but nothing changes.
The Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'will_paginate', '~> 3.0'
gem "bcrypt-ruby", :require => "bcrypt"
gem 'mysql'
#Problems in Debian, the error was:
#Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs #for a list of available runtimes. (ExecJS::RuntimeUnavailable)
#Solution: http://stackoverflow.com/questions/6282307/rails-3-1-execjs-and-could-not-find-a-javascript-runtime
gem 'execjs'
gem 'therubyracer'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5.rc.2'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', '0.8.2', :require => false
end
Change your Gemfile (move coffee-rails gem outside the assets group) or change your application.rb settings - for instance
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
# Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
Bundler.require(:default, :assets, Rails.env)
end
In development environment application by default loads all of gems from :default, :development, :test, :assets groups. Coffee handler comes from coffee-rails gem, so you have to load it.

test-unit gem displays test stat for every rake run

I using test-unit gem with a Rails 3.1 project, and I have a small issue. If I start rake tasks, I always see a test result, with zeros.
My Gemfile is:
source :rubygems
gem 'rails', '3.1.2'
gem 'sqlite3'
gem 'json_pure'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# gem 'sass-rails', '~> 3.1.5.rc.2'
# gem 'coffee-rails', '~> 3.1.1'
gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# Rails i18n
gem 'rails-i18n', :git => 'git://github.com/hron84/rails-i18n.git'
# Paginator
gem 'will_paginate'
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
gem 'thin'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
group :development do
gem 'rails3-generators'
gem 'nifty-generators'
end
group :test do
gem 'rspec'
gem 'rspec-rails'
gem 'ci_reporter'
gem 'factory_girl'
unless defined? Rubinius
gem 'rcov'
gem 'rcov_rails'
gem 'test-unit'
end
gem 'ruby-prof'
gem 'faker'
end
# Application-related stuffs
gem 'authlogic'
# Slug helper
gem 'slug'
# vim: ft=Gemfile
Is there a way to avoid it? What I do wrong?
Check your RAILS_ENV. Make sure it's set to "development", not "test". If that's not the culprit, try removing gems (particularly test/spec-related ones) one by one until the problem goes away. Then you'll know which gem is giving you the problem.