jquery-ui-rails gem doesn't work on preexisting project - ruby-on-rails

I'm using the jquery-ui-rails gem to create a slider, however it does not work on a preexisting project for some odd reason. If I create a new project (rails new blog), generate a user scaffold, then add gmaps4rails gem and then jquery-ui-rails gem the map and slider work and appear just fine. However if I open an older project, follow the exact same steps (adding same columns etc), the map will appear fine but the slider will not appear. Does anyone know why this is/how to fix it?
This is my gemfile in case there are any gems that cause conflicts
source 'http://rubygems.org'
gem 'rails', '3.2.8'
gem 'mysql2'
# 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 'uglifier', '>= 1.0.3'
gem 'jquery-ui-rails'
end
gem 'jquery-rails'
gem 'gmaps4rails'
gem 'bcrypt-ruby', :require => "bcrypt"
gem 'mail'

found the issue, after adding the jquery-rails-ui gem you need to run bundle exec rake assets:precompile in the command line for it to work.

It could be that you are including jquery-ui-rails only in the assets group. The gems in the assets group are only used during asset pipeline operations.
Move jquery-ui-rails outside of the assets group, run 'bundle install', and see if it works.

Related

Warning regarding not using bundler when running guard init

In my Rails app am getting this warning when running guard init rspec:
Warning: you have a Gemfile, but you're not using bundler or
RUBYGEMS_GEMDEPS
14:54:15 - INFO - Writing new Guardfile to
/home/ubuntu/railsprojects/sillyfish/Guardfile 14:54:16 - INFO - rspec
guard added to Guardfile, feel free to edit it
I don't understand why it's showing. Is it okay to ignore this warning?
Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.4'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'rspec-rails', '3.3.3'
gem 'guard-rspec', require: false
gem 'spring-commands-rspec'
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :test do
gem 'capybara', '2.5.0'
end
#custom gems
gem 'puma'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'devise', '~> 3.5.2'
If you run guard init rspec, it will use the globally installed guard-rails. To run the one installed through your Gemfile, use bundle exec guard init rspec. This is also what is recommended in the documentation.
From the README:
It's important that you always run Guard through Bundler to avoid errors.
So it's probably best to take this warning seriously, to avoid issues down the line.
A more technical answer:
There are 3 ways gems can be selected for your Ruby (or Rails) projects:
As they are installed on your system (by looking at environment variables such as $GEM_HOME), e.g. guard init rspec will look for guard and guard-rspec in your $GEM_HOME. Usually RubyGems will use the latest installed versions you have installed (not always what you'll want).
If you have Bundler, bundle exec guard init rspec will cause your gems to be loaded in versions listed in your Gemfile.lock. This also allows you to load gems directly from other folders (anywhere using :path option in your Gemfile) bundled with the app (e.g. .bundle directory) or even downloaded and updated from GitHub (using :github, :branch, etc. options).
If you have a recent version of RubyGems, it can also load your gems from a Gemfile.lock. But only if you have the $RUBYGEMS_GEMDEPS environment properly set up. It works like Bundler (it reads your Gemfile.lock), except it doesn't have all the features (like loading gems from a GitHub repository).
In general, if your project has a Gemfile, it's best to use Bundler, because it makes sure all the versions of all gems are matched up to what you expect.

downgrading rails project from 3.2.1 to 2.3.3

My first Rails project deploy, and I've run into an issue.
The project is Rails 3.2.1, Ruby 1.9.3
Yesterday, I was given the hosting access, and they're having Rails 2.3.3, Ruby 1.8.7
If I'll decide to still deploy the app there, what changes do I need to make to it?
Specifically, I'm interested in Gemfile changes.
Here's my current gemfile:
source 'https://rubygems.org'
gem 'rails', '2.3.3'#'3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# 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'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'haml-rails'
gem 'haml'
gem 'omniauth-twitter'
What do I need to change? How do I look-up all the required dependencies and gems versions for old Rails versions?
Downgrading from 3.x to 2.3 is the dumbest thing you can do in your case.
Install gems locally, or ask your hosting company support department — they have to help.
If you can't, save your time — use Heroku, OpenShift or any other hosting company.

running rails 3.2 / mongoid app on heroku fails

I'd like to now if anybody could help me with my heroku deployement.
I've set up my Rails 3.2 app with the following Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'mongoid'
gem 'bson_ext'
gem 'mongoid_slug'
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'
gem "compass", ">= 0.12.alpha"
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
And I have run the rails g mongoid:config command
From the heroku support, I've added the mongolab extension and changed the mongoid.yml evironnement variables to MONGOLAB_URI
When I then deploy the app, it doesn't run on heroku.
I'm not sure what is going on, but i get this error message in the Heroku logs:
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionmailer-3.2.0.gemspec'
2012-01-29T19:13:46+00:00 app[web.1]: Could not find activemodel-3.2.0 in any of the sources
here is the full log file:
https://gist.github.com/1700231
has anybody experienced the same issue? I'm not sure if the problem comes from my set up or if I need to add something to rails to work with mongoid?
Cheers.
It's been a bit of pain int the b*tt, but I'm finally there.
http://railsapps.github.com/rails-heroku-tutorial.html
is the right place to go to deplay rails 3.2 on heroku.
This said my head hurt, not too much fun to get so many hurdles when one wants to learn.
Octopress looks fine at the moment I tell you :)
Alright let's keep going

application.js isn't precompiled

I'm not sure why, but whenever I run rake assets:precompile, application.js doesn't get compiled. I get a "application.js isn't precompiled" error in production mode.
Here is my Gemfile if it means anything:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'eventmachine', '1.0.0.beta.4.1'
gem 'thin'
gem 'mysql'
gem 'win32-open3-19'
gem 'paperclip', '2.3.8'
#gem 'jammit'
gem 'jsmin'
gem 'will_paginate'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
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', :require => false
end
I made a new rails app and tested the rake assets:precompile and it's working. The only difference between the two apps in terms of relevant files would be what gems I have installed. "application.js" is the same between both apps...as are the environment.rb files.
Also of note...when I include a random .js file in my assets/javascripts directory and use "javascript_include_tag :application", one of the resulting URLs in dev mode look like so: /assets/../javascripts/anytimec.js?body=1 and they obviously fail with 404. However the application.js file is referenced correctly.
UPDATE:
Looking into what Sprockets generates I've noticed that the "logical path" uses "../javascripts" in the location. I tested this by looking at the dump of asset_paths.asset_for('application','js') and asset_paths.asset_for('anytimec','js') respectively. I've also compared those dumps to the same files from a fresh application. The fresh application does NOT prepend the "../javascripts" to the location whereas my current app DOES. It doesn't do this to the CSS files or anything else...just javascript. This is most definitely alluding to the core problem but I don't know where to go from here.
After discovering that it had to do with Sprockets failing when reading a folder specifically called "java" in the assets folder, I renamed it to "applets" and it started working.
See this post for the answer.

Sprockets generating incorrect logical_path for javascript files

Sprockets seems to make an error in determining the logical_path of my javascript assets (except for application.js). It prepends "../javascripts" to the path and so my references are wrong and the application.js file won't precompile. I'm using Rails Thin server on Windows.
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'eventmachine', '1.0.0.beta.4.1'
gem 'thin'
gem 'mysql'
gem 'win32-open3-19'
gem 'paperclip', '2.3.8'
gem 'jsmin'
gem 'will_paginate'
gem 'jquery-rails'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
I've created a new app and on it's own, there are no problems. It's only when I copy the files from my current app over that the problem starts. I've tried disabling all extraneous gems but the problem persists (leading me to believe it's not a gem that's causing the problem).
Wow. Apparently Sprockets pukes invisible chunks when it finds a folder called "java" under "assets" and simply doesn't process anything else from that point forward for js files. Under /assets I had "images", "javascripts", "java" (for java applets) and "stylesheets". Changing "java" to "applets"
"FIXED"
the problem.

Resources