I'm following ruby on rails tutorials 3.2 by Michael Hartl but when i put gem 'factory_girl_rails', '1.4.0' in my gemfile and run bundle install it shows "bundle complete" as the gem is already loaded in my PC. My problem is it's not generating the factories.rb file in spec folder. What is going wrong?
Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.9.0'
gem 'annotate', '~> 2.4.1.beta'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
end
group :production do
gem 'pg', '0.12.2'
end
routes.rb:
SAMPLEApp::Application.routes.draw do
resources :users
root to: 'static_pages#home'
match '/signup', to: 'users#new'
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
end
Running bundle install won't add any files to your Rails application. It will just download the proper libraries that it needs to use. Sometimes these libraries will come with a rails generator and you would run something like rails generate some_library:install. I don't think that's the case with factory_girl_rails. You probably need to add the file manually.
Related
I'm using RefineryCMS as a rails CMS, it was working like a charm until I followed the answer in this question to get a simple image gallery functionality going. Now I'm getting the same error as shown on this issue. I didn't change any of my rails code to introduce a link_to tag with a nil reference, however (there is a link_to image_tag line in the guide but I've commented that out and nothing changed), so it's happening in the autogenerated code I believe. Here's the full error I get when I login to refinery on my site:
ActionController::UrlGenerationError in Refinery::Authentication::Devise::Admin::Users#index
Showing /home/mpvoss/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-0a37f8090278/core/app/views/refinery/admin/_menu_item.html.erb where line #1 raised:
No route matches {:action=>"index", :controller=>"refinery/refinery/portfolio/admin/galleries", :locale=>:en}
Extracted source (around line #46):
44 message << " missing required keys: #{missing_keys.sort.inspect}" unless missing_keys.empty?
45
46 raise ActionController::UrlGenerationError, message
47 end
48
49 def clear
Trace of template inclusion: /home/mpvoss/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-0a37f8090278/core/app/views/refinery/admin/_menu.html.erb, /home/mpvoss/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-0a37f8090278/core/app/views/layouts/refinery/admin.html.erb
Note: Just loading the website without logging into refinery works because it's not trying to load the menu code below that encounters the routing issue.
Okay, let's have a look at _menu.html.erb
<%= link_to menu_item.title, refinery.url_for(menu_item.url),
:class => ("active" if menu_item.highlighted?(params)),
:id => "plugin_#{menu_item.name}" %>
This code just makes a menu bar for all the plugins. It can be commented out and refinery works (the error above goes away), but I need that menu bar to make changes to the website.
What I've tried.
I found a galleries_controller.rb in ~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-portfolio-289b85b18771/app/controllers/refinery/portfolio/admin, which seems to be the controller the error was talking about. It didn't have an index action, so I added an empty action to see if that was the problem and nothing changed. The routes.rb for the ~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-portfolio-289b85b18771/ gem is below
Commenting out the portfolio gem in my Gemfile and running bundle install but I get the same error because the autogenerated code (referring to stuff like .rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-0a37f8090278/) is still getting executed (I use git for version control and make a clean clone of the project before these changes and it has the same problem because the autogenerated code is not part of the version control).
gem uninstall of the refinery-photo-gallery, refinerycms-page-images and refinerycms-portfolio gems I thought might be causing the problem
I moved all the gems in ~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/ out of that directory to see if a bundle install would regenerate fresh, clean gems but nothing changed.
None of these ideas has made a difference. If any clarification is needed please just let me know. I've been stumped on this for a week and my Googling skills are failing me. Any help is really appreciated!
~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-portfolio-289b85b18771/routes.rb
Refinery::Core::Engine.routes.draw do
# Frontend routes
namespace :portfolio, :path => Refinery::Portfolio.page_url do
root :to => "galleries#index"
resources :galleries, :only => [:index, :show]
end
# Admin routes
namespace :portfolio, :path => '' do
namespace :admin, :path => Refinery::Core.backend_route do
scope :path => 'portfolio' do
resources :galleries, :except => :show do
get :children, :on => :member
post :update_positions, :on => :collection
resources :items, :except => [:show] do
post :update_positions, :on => :collection
end
end
resources :items do
post :update_positions, :on => :collection
end
end
end
end
end
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3'
end
# Use SCSS for stylesheets
# Use Uglifier as compressor for JavaScript assets
# Use CoffeeScript for .coffee assets and views
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# 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
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
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'
end
# Added by Matthew, Thin server
gem 'faye'
gem 'thin'
group :assets do
#gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 4.1.0'
gem 'sass-rails', '~> 5.0'
#gem 'coffee-rails', '~> 3.2.1'
gem 'bootstrap-sass','~> 3.1.1'
gem 'uglifier', '>= 1.3.0'
#gem 'uglifier', '>= 1.0.3'
end
gem 'twitter-bootstrap-rails'
gem 'refinerycms', git: 'https://github.com/refinery/refinerycms', branch: 'master'
#gem 'refinerycms-page-images', '~> 2.0.0'
gem 'quiet_assets', group: :development
#gem 'refinerycms-photo-gallery', '~> 0.1.0'
# Add support for searching inside Refinery's admin interface.
gem 'refinerycms-acts-as-indexed', ['~> 2.0', '>= 2.0.0']
# Add support for Refinery's custom fork of the visual editor WYMeditor.
gem 'refinerycms-wymeditor', ['~> 1.0', '>= 1.0.6']
gem 'refinerycms-portfolio', github: 'refinery/refinerycms-portfolio', branch: 'master'
# The default authentication adapter
gem 'refinerycms-authentication-devise', '~> 1.0'
Looks like it was a bug in the portfolio/images plugin, tried another bundle update and the updated code worked like a charm. <3 RefineryCMS contributors
I am attempting to upgrade an application from Rails 2.3 to 3.2. The issue I am currently stuck with is that Rails.application.routes.url_helpers is missing in views.
So, for example, my routes.rb file contains (in part):
MyApp::Application.routes.draw do
resources :users
end
and running rake routes shows me that I have the following:
users GET /users(.:format) users#index
POST /users(.:format) users#create
However, when I try to use the users_path in a HAML view, such as in the following example:
- if logged_in?
%ul.nav
- if user_can?(:see_users?)
%li.users= link_to "Users", users_path
Then I get the following error:
undefined local variable or method `users_path' for #<#<Class:0x000001045eda80>:0x000001030f6bb8>
However, if the ApplicationController is changed to include:
include Rails.application.routes.url_helpers
then everything is okay. The question is, why is that helper not automatically available in the views after the upgrade?
Update: As requested in comment below, the Gemfile is:
source 'http://rubygems.org'
source 'http://gems.github.com'
gem 'rails', '3.2.13'
gem 'rake', '10.0.4'
gem 'haml', '3.1.4'
gem 'responders', '0.9.3'
gem 'inherited_resources', '1.4.0'
gem 'formtastic', '2.2.1'
# Note: validation_reflection coming from git for now as it has the fix for
# https://github.com/redinger/validation_reflection/pull/13 in it, while the
# current official 1.0.0 release does not have the fix. Can be changed back
# to a version number if 1.0.1 is released.
gem 'validation_reflection', :git => 'git://github.com/redinger/validation_reflection.git'
gem 'treetop'
gem 'authlogic', '3.1.2'
gem 'param_protected', '2.0.0'
gem 'chronic', '0.2.3'
gem 'amon', '0.12.0'
gem 'aws-sdk', '1.9.5'
gem 'paperclip', '3.4.1'
gem 'json', '~> 1.4.3'
gem 'airbrake', '~> 3.0.5'
gem 'bluecloth', '>= 2.0.0'
gem 'less'
gem 'therubyracer'
gem 'mysql'
gem 'rdoc'
gem 'thin', '1.3.1'
gem 'delayed_job', '3.0.5'
gem 'delayed_job_active_record'
gem 'will_paginate', '3.0.4'
gem 'newrelic_rpm'
gem 'tiny_mce'
gem 'geocoder'
gem 'safe_attributes'
group :development do
gem 'capistrano', "~> 2.13.5"
gem 'capistrano-ext'
gem 'rvm-capistrano'
gem 'ci_reporter', '1.6.5'
end
group :development, :test, :cucumber do
gem 'pry'
gem 'rspec', '1.3.2'
gem 'rspec-rails', '~> 1.3.0', :require => 'spec'
gem 'email_spec', '0.6.5'
gem 'seed-fu'
end
group :test do
gem 'mocha', '0.9.8'
gem 'machinist', '1.0.6'
gem 'faker', '0.3.1'
gem 'timecop', '0.3.5'
gem 'fakeweb', '1.3.0'
gem 'shoulda'
gem 'uuid', "~> 2.3.7" # MIT
end
group :cucumber do
gem "cucumber", "~> 1.1.0"
gem "cucumber-rails", "~> 0.3.2"
gem "capybara", "~> 1.1.1"
gem 'database_cleaner', "~> 0.5.0"
gem 'launchy'
gem 'uuid', "~> 2.3.7" # MIT
end
I tried to deploy an application.war file into webapps/ in the tomcat folder and started up the server. When i try to open http://localhost:8080/relConnections it shows on the screen that "something went wrong". I deleted the common index.html in the public folder in usual rails apps and tchanged the root to my home page.
When i see the log file it says the following:
"An exception happened during JRuby-Rack startup private method `gsub' called for nil:NilClass
--- System
jruby 1.6.7"
and three or four more excecption saying the same lines gsub nil:NilClass for all of those.
Here is my Gemfile
source 'http://rubygems.org'
gem 'jruby-jars', '1.6.7'
gem 'warbler', '1.3.2'
gem 'rails', '3.1.3'
gem 'rake', '0.9.2.2'
gem 'jruby-openssl', '0.7.5', :platforms => :jruby
gem 'json', '1.6.5', :platforms => [:jruby, :mingw, :mingw_19]
gem 'therubyrhino', :platforms => :jruby
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activerecord-jdbc-adapter', '1.2.2'
gem 'activerecord-oracle_enhanced-adapter', '1.4.0'
gem 'mechanize', '1.0.0'
gem 'nokogiri', '1.5.0'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'ruby-debug-base', '0.10.4'
gem 'ruby-debug-ide', '0.4.17.beta8'
gem 'pry', '0.9.7.4'
end
group :test do
gem 'turn', '0.8.3', :require => false
gem 'minitest', '2.11.0'
gem 'timecop', '0.3.5'
end
gem 'jruby-pageant', '~>1.0.2'
gem 'net-ssh', '~>2.5.2'
And here is my warble.rb
Warbler::Config.new do |config|
#commented code
config.dirs = %w(app config lib log vendor tmp)
#more commented code
end
Let me know if iam missing any gems or anything else here.
Thanks
I think you may try to set the jruby version to 1.9. In the warble.rb
config.webxml.jruby.compat.version = "1.9"
I have Rails 3.2.1 and try to install devise (1.1.rc0) with ubuntu
My rake routes give me
new GET /users/registration/sign_up(.:format) devise/registrations#new
config/routes.rb
DeviseApp::Application.routes.draw do
devise_for :users
match "users/registration/sign_up" => "devise/registrations#new"
resources :projects
root :to => "home#index"
end
when http://127.0.0.1:3000/users/registration/sign_up
I take
undefined method `user_registration_path' for Class
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'sqlite3'
gem 'devise', '1.1.rc0'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I follow instructions from episode 209 Introducing Devise Railscasts.
You have to define the route as a named route if you want to use user_registration_path
match "users/registration/sign_up" => "devise/registrations#new", :as => 'user_registration'
The final solution was to change the Gemfile. New Gemfile:
gem 'rails', '3.0.11'
gem 'sqlite3', '1.3.3'
gem 'devise'
gem 'recaptcha', :require => 'recaptcha/rails'
Maybe the combination rails '3.2.1' and devise '1.1.rc0' was catastrophic for me.
I'm going through the Rails 3 in Action eBook and they've put a lot of emphasis on testing but I can't seem to get Cucumber to work for some reason.
I keep getting a Rake aborted! Stack level too deep error when I use to rake cucumber:ok command.
Anyone know what might be causing this?
Here's my gem file:
source 'http://rubygems.org'
gem 'rails', '3.1.1.rc1'
# 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.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test, :development do
gem 'rspec-rails', '~> 2.5'
end
group :test do
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
end
Use
bundle exec rake cucumber:ok