How to include gems in the project using Rails 2 and Ruby 1.9.3? - grails-2.0

I have the project built using
Rails 2.3.18
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
I do not have any Gemfile my project so how include gems in it.

edit the app/config/environment.rb
config.gem 'will_paginate', :version => '~> 2.3.16'
config.gem 'ssl_requirement'
config.gem "ambethia-recaptcha", :lib => "recaptcha/rails", :source => "http://gems.github.com"

Related

berkshelf unable to resolve chained git dependency

C:\git\test (master) × berks --version
7.0.8
I have an issue with Berkshelf resolving chained git dependencies.
I have a test cookbook I generated to narrow down the issue, this cookbook depends on the cookbook windows-automation via a git reference.
test Berksfile
# frozen_string_literal: true
source 'https://supermarket.chef.io'
cookbook 'win-telegraf', path: '../win-telegraf/'
cookbook 'windows-automation', '~> 0.4.0', git: 'git#git.osky.io:ops/chef-windows-automation.git', branch: 'master'
# cookbook 'windows-library', '~> 0.1.0', git: 'git#git.osky.io:ops/chef-windows-library.git', branch: 'master'
metadata
test metadata.rb
depends 'win-telegraf'
depends 'windows-automation', '~> 0.4.0'
# depends 'windows-library', '~> 0.1.0'
windows-automation depends on windows-library via another git reference
windows-automation Berksfile
source 'https://supermarket.chef.io'
metadata
cookbook 'powershell', '~> 6.1.3'
cookbook 'windows', '~> 4.2.5'
# cookbook 'windows-library', path: '../chef-windows-library'
cookbook 'windows-library', '~> 0.1.0', git: 'git#git.osky.io:ops/chef-windows-library.git', branch: 'master'
windows-automation metadata
supports 'windows'
depends 'powershell', '~> 6.1.3'
depends 'windows-library', '~> 0.1.0'
This issue comes when I try to run berks install for the test cookbook. I get the following output
C:\git\test (master) × berks install
Resolving cookbook dependencies...
Fetching 'test' from source at .
Fetching 'win-telegraf' from source at ../win-telegraf
Fetching 'windows-automation' from git#git.osky.io:ops/chef-windows-automation.git (at master)
Fetching cookbook index from https://supermarket.chef.io...
Unable to satisfy constraints on package windows-library, which does not exist, due to solution constraint (test = 0.1.0). Solution constraints that may result in a constraint on windows-library: [(test = 0.1.0) -> (windows-automation = 0.4.0) -> (windows-library >= 0.0.0)], [(windows-automation = 0.4.0) -> (windows-library >= 0.0.0)]
Missing artifacts: windows-library
Demand that cannot be met: (test = 0.1.0)
Unable to find a solution for demands: test (0.1.0), win-telegraf (0.1.0), windows-automation (0.4.0)
This issue gets resolved if in the test cookbook I add a dependency to windows-library. But I am wondering why berkshelf cannot resolve this without the dependency. I feel like I should not need to explicitly depend on all transative git dependencies.
Known issue with berkshelf that is marked as wontfix.
https://github.com/berkshelf/berkshelf/issues/1829

Rails adds extra <style> tags to the rendered page

My application is working perfectly in development environment, but when I switched to production environment I found that the styles look a bit different. After some tracing, I noticed that these tags:
<style type="text/css" media="screen">…</style>
<style type="text/css" media="media">…</style>
<style type="text/css" media="print">…</style>
were added to the head tag overriding my application.css styles.
Is there any way to stop these tags from being added to the rendered page?
Updtae
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
# gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'devise'
gem 'carrierwave'
gem 'rmagick'
gem 'mysql2'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# To include font-awesome icons
# gem 'twitter-bootstrap-rails'
# gem 'bootstrap-sass'
gem 'font-awesome-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
gem 'capistrano', '~> 3.1.0'
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0'
# integrate bundler with capistrano
gem 'capistrano-bundler'
# if you are using RBENV
gem 'capistrano-rbenv', "~> 2.0"
gem 'capistrano-rvm'
group :development, :test do
# Call 'byebug' anywhere in the code to stop
# execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application
# running in the background.Read more: https://github.com/rails/spring
gem 'spring', '~> 1.3.4'
end
group :production do
gem 'rails_12factor'
end
production.rb
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.assets.compile = true
config.assets.precompile = ['*.js', '*.css', '*.css.erb']
config.active_record.dump_schema_after_migration = false
end
Changing the default order in the head tag inside app/views/layouts/application.html.erb from
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= favicon_link_tag 'favicon.ico' %>
<%= csrf_meta_tags %>
to
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= favicon_link_tag 'favicon.ico' %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
solved the problem and no extra style tags were added to the rendered page.

Rails 4 Database cleaner

I'm trying to complete some tests for a rails 4 app and I keep encountering an issue with database_cleaner.
The issue is the database is not being cleaned and warnings keep raising:
DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
WARNING: there is already a transaction in progress
.FFFFDEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.WARNING: there is already a transaction in progress
DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
WARNING: there is already a transaction in progress
The configuration I have setup in the spec helper is:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
# require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.filter_run focus: true
config.run_all_when_everything_filtered = true
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
# config.use_transactional_fixtures = false
config.before :each do
if Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strategy = :truncation
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
# config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
end
And finally here is my gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.beta1'
gem 'pg'
gem 'haml-rails', '~> 0.4'
gem 'twitter-bootstrap-rails', '~> 2.2.0'
gem 'annotate', '~> 2.5.0'
group :test do
gem 'rspec', '~> 2.13.0'
gem 'rspec-rails', '~> 2.13.0'
gem 'guard-rspec', '~> 1.2.1'
gem 'guard-spork', '~> 1.4.2'
gem 'capybara', '~> 2.0.2'
gem 'spork', '~> 0.9.2'
gem 'factory_girl_rails', '~> 4.1.0'
gem 'shoulda-matchers', '~> 1.4.2'
gem 'database_cleaner', '~> 0.9.1'
gem 'launchy', '~> 2.2.0'
gem 'rb-fsevent', '~> 0.9.2'
gem 'growl', '~> 1.0.3'
end
group :development do
gem 'better_errors' ,'~> 0.6.0'
gem 'binding_of_caller', '~> 0.7.1'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.0.1'
Any help on this issue would be really helpful. Thank you!
It looks like this is fixed by the 1.0.0 RC1 release of database_cleaner. Try this in your Gemfile:
gem "database_cleaner", '1.0.0.RC1'

Symfony2 - DoctrineFixturesBundle - DoctrineCommand not found

I'm trying to manually add DoctrineFixturesBundle to my symfony project when I do so I get the following error.
C:\wwwnet\symfony>php app/console doctrine:fixtures:load
Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand' not found in C:\wwwnet\symfony\vendor\bundles\Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand.php on line 34
I've followed the steps out lined here How to install a Symfony 2.0 Bundle from Zip file
In my AppKernel I have added:
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
In autoload I have:
'Doctrine\\Bundle' => __DIR__.'/../vendor/bundles',
//'Symfony\\Bundle\\DoctrineFixturesBundle' => __DIR__.'/../vendor/bundles',
//'Doctrine\\Bundle\\DoctrineFixturesBundle' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
I have added the bundle to:
C:\wwwnet\symfony\vendor\bundles\Doctrine\Bundle\FixturesBundle
I've seen this question Symfony2 DoctrineFixturesBundle namespace error and it seems to suggest I am probably using the 2.1 bundle with 2.0 symfony
Also, the DoctrineBundle will never be in the Doctrine\Bundle namespace as long as you are on Symfony 2.0.x. Symfony 2.0.x ships with the DoctrineBundle under bundles\Symfony. Your problem is that you are trying to use a too new version of the DoctrineFixturesBundle which expects the DoctrineBundle under Doctrine\Bundle. My first suggestion, tagging the bundle to version=origin/2.0 should solve this. – leek Mar 11 at 20:22
How do I grab the 2.0 bundle for https://github.com/doctrine/DoctrineFixturesBundle? If that is even the problem, I am in the dark on this and have been scratching my head aimlessly for two days now.
Symfony: Symfony_Standard_Vendors_2.0.16
PHP: 5.3.6
Apache: 2.2
In your deps file add
[doctrine-fixtures]
git=http://github.com/doctrine/data-fixtures.git
[DoctrineFixturesBundle]
git=http://github.com/doctrine/DoctrineFixturesBundle.git
target=/bundles/Symfony/Bundle/DoctrineFixturesBundle
version=origin/2.0
so you are defining version in the last line, do a bin/vendor update after that

Problem migrating w/ sqlite3, receive error message-> undefined method `prerequisites' for nil:NilClass

I'm working on the RoR3 Tutorial and i'm on chapter 6 when I tried the rakedb:migrate command. I received the message:
rake aborted!
undefined method `prerequisites' for nil:NilClass
I ignored the changes to the Gemfile because it already was installing sqlite3. When I changed it to 'sqlite3-ruby', '1.2.5' :required => 'sqlite3', i got an ActiveRecord::ConnectionNotEstablished message when trying to view the page locally. So, I just decided to not make that change.
I am using lion os, ruby 1.9.2p290, rails 3.1.0.rc8. Thx!
I'm working on the same tutorial at the moment, and ran into the same issue. After some digging, it turns out this is a bug with rspec-rails. If you look at rpsec-rails' change log for 2.6.1
guard against calling prerequisites on nil default rake task (Jack
Dempsey)
the book also doesn't get a chance to go into detail on what's going on when you run "bundle install", turns out bundler is meant to solve application dependencies: http://gembundler.com/rationale.html
Anyway, this was the solution: https://github.com/rails/rails/issues/1723
Change 'rspec-rails' under :development in your gemfile to:
gem 'rspec-rails', '2.6.1.beta1'
and 'rspec' under :test to
gem 'rspec', '2.6'
worked for me. Let me know if you want to work through the book together!

Resources