Rails 3 paperclip install, now get LoadError - paperclip

I am very new to Rails, I am running Rails 3
I recently installed ImageMagick via Homebrew and then ran 'sudo plugin install git://github.com/thoughtbot/paperclip.git'
I added "gem 'rmagick'" to my root Gemfile.
Immediately after doing so I found that no rails commands worked anymore (error below). I tried adding "config.gem "rmagick", :lib => "RMagick"" to my environment.rb as some other threads suggested, but this returns a different error (undefined local variable or method `config' for main:Object (NameError))
Any thoughts?
/opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require': no such file to load -- cocaine (LoadError)
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/vendor/plugins/paperclip/lib/paperclip.rb:43
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/vendor/plugins/paperclip/lib/paperclip/railtie.rb:1
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/vendor/plugins/paperclip/rails/init.rb:1
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/plugin.rb:81
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `run_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/config/environment.rb:5
from /Users/tonybeninate/Documents/Apps/PhotoBlog/config.ru:3:in `require'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/config.ru:3
from /opt/local/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
from /opt/local/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/config.ru:1:in `new'
from /Users/tonybeninate/Documents/Apps/PhotoBlog/config.ru:1

I cloned your repo and ran the app but didn't get any of those errors. Have you tried installing paperclip as a gem instead of a plugin?
This is the setup I have working in one of my apps (using Amazon S3 for storage):
# Gemfile
gem 'paperclip'
gem 'aws-s3'
#MyModel migration
class MyModel < ActiveRecord::Migration
def self.up
create_table :my_model do |t|
t.string :name
t.text :description
t.string :image_file_name
t.string :image_content_type
t.integer :image_file_size
t.datetime :image_updated_at
t.timestamps
end
end
end
#MyModel.rb
has_attached_file :image,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/amazons3.yml",
:path => "pictures/:id.:extension"
#config/amazons3.yml
development:
access_key_id: MY_ACCESS_KEY_ID
secret_access_key: MY_SECRET_KEY
bucket: myBucket
test:
access_key_id: MY_ACCESS_KEY_ID
secret_access_key: MY_SECRET_KEY
bucket: myBucket
production:
access_key_id: MY_ACCESS_KEY_ID
secret_access_key: MY_SECRET_KEY
bucket: myBucket
#app/views/my_model/_form.html.haml
= form_for #my_model_instance, :html => {:multipart => true} do |f|
%fieldset
= f.label :name
= f.text_field :name
%fieldset
= f.label 'Attach Image'
= f.file_field :image
%fieldset
= f.label :description
= f.text_area :description
%fieldset
= f.submit 'Save', :class => 'button'

You get an error if you run on development mode, write this in terminal rails s to run development mode
this
:s3_credentials => "#{RAILS_ROOT}/config/amazons3.yml",
change to, for work correctly with Rails 3
:s3_credentials => "#{Rails.root}/config/amazons3.yml",

Related

Rails could not find the inverse association in has many relation

I have two models (one to many relationship between them) in rails 5,
One is ScholarshipGroup and Scholarship model with Admin namespace.
ScholarshipGroup Model:
class Admin::ScholarshipGroup < ApplicationRecord
has_many :admin_scholarships, :class_name => 'Admin::Scholarship',inverse_of: :admin_scholarship_group
end
And Scholarship Model:
class Admin::Scholarship < ApplicationRecord
belongs_to :group, :class_name=> 'Admin::ScholarshipGroup', inverse_of: 'admin_scholarships'
end
I want to need data for all scholarships under a ScholarshipGroup.
But when I run this query from rails console:
$ Admin::ScholarshipGroup.first.admin_scholarships.first
But it gives me this error:
Admin::ScholarshipGroup Load (0.3ms) SELECT "admin_scholarship_groups".* FROM "admin_scholarship_groups" ORDER BY "admin_scholarship_groups"."id" ASC LIMIT ? [["LIMIT", 1]]
ActiveRecord::InverseOfAssociationNotFoundError: Could not find the inverse association for admin_scholarships (:admin_scholarship_group in Admin::Scholarship)
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activerecord-5.0.0.1/lib/active_record/reflection.rb:202:in `check_validity_of_inverse!'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activerecord-5.0.0.1/lib/active_record/reflection.rb:402:in `check_validity!'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activerecord-5.0.0.1/lib/active_record/associations/association.rb:25:in `initialize'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activerecord-5.0.0.1/lib/active_record/associations.rb:235:in `new'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activerecord-5.0.0.1/lib/active_record/associations.rb:235:in `association'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activerecord-5.0.0.1/lib/active_record/associations/builder/association.rb:111:in `admin_scholarships'
from (irb):34
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/ubuntu/workspace/bin/rails:9:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.1#college/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
Why do return this type error ? Can anyone suggest me the solution of this error ?
You defined belongs_to :group in Admin::Scholarship model.
You can try:
has_many :admin_scholarships, :class_name => 'Admin::Scholarship',inverse_of: :group, foreign_key: 'group_id'

NoMethodError: undefined method `validates_confirmation_of' Sinatra

Im getting the above error but dont understand why. Here is the stack trace:
/Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/app/models/user.rb:8:in `<class:User>': undefined method `validates_confirmation_of' for User:Class (NoMethodError)
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/app/models/user.rb:4:in `<top (required)>'
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/app/data_mapper_setup.rb:6:in `require_relative'
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/app/data_mapper_setup.rb:6:in `<top (required)>'
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/app/app.rb:4:in `require_relative'
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/app/app.rb:4:in `<top (required)>'
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/spec/spec_helper.rb:3:in `require'
from /Users/benrumble/Desktop/Apple_tv_movies_and_stuff/skeletons/Full_Stack_Sinatra_App_Skeleton/Skeleton_App_with_user_login:sign_up_and_bcrypt/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration.rb:1394:in `require'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration.rb:1394:in `block in requires='
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration.rb:1394:in `each'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration.rb:1394:in `requires='
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration_options.rb:112:in `block in process_options_into'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration_options.rb:111:in `each'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration_options.rb:111:in `process_options_into'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/configuration_options.rb:21:in `configure'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/runner.rb:99:in `setup'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/runner.rb:86:in `run'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/runner.rb:71:in `run'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.0/exe/rspec:4:in `<top (required)>'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `load'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `<main>'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/benrumble/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
and here is the user.rb model
require 'bcrypt'
require 'dm-validations'
class User
attr_reader :password
attr_accessor :password_confirmation
validates_confirmation_of :password
include DataMapper::Resource
property :id, Serial
property :email, String
property :password_digest, String, length: 60
def password=(password)
#password = password
self.password_digest = BCrypt::Password.create(password)
end
end
I tried with and without 'dm-validations' but it doesnt make a difference.
Any help would be great.
Thanks
I solved this issue by moving the
include DataMapper::Resource
line as the first line after declaring the class.

Upgrading to Rails4 and I cant pass this devise test that passed in Rails3

undefined local variable or method `login_user'
Why are my controllers not getting the extended ControllerMacros ???
Commit in question: https://github.com/shadowbq/cartoque/commit/2fba99c6eac5f9f2f0da2dd464f475cae0bae520
<snip>
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
<...snip>
<snip>
# include devise helpers in controller specs
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
<...snip>
/usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/example_group.rb:675:in `method_missing': undefined local variable or method `login_user' for RSpec::ExampleGroups::BackupExclusionsController:Class (NameError)
from /home/shadowbq/sandbox/cartoque/spec/controllers/backup_exlusions_controller_spec.rb:5:in `block in <top (required)>'
<snip>
module ControllerMacros
def login_admin
before(:each) do
#request.env["devise.mapping"] = Devise.mappings[:admin]
#user = FactoryGirl.create(:admin)
sign_in #user
end
end
def login_user
before(:each) do
#request.env["devise.mapping"] = Devise.mappings[:user]
#user = FactoryGirl.create(:user)
sign_in #user
end
end
end
<...snip>
Here is full backtrace as well..
/usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/example_group.rb:675:in `method_missing': undefined local variable or method `login_user' for RSpec::ExampleGroups::BackupExclusionsController:Class (NameError)
from /home/shadowbq/sandbox/cartoque/spec/controllers/backup_exlusions_controller_spec.rb:5:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/example_group.rb:385:in `module_exec'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/example_group.rb:385:in `subclass'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/example_group.rb:255:in `block in define_example_group_method'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/dsl.rb:43:in `block in expose_example_group_alias'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/dsl.rb:82:in `block (2 levels) in expose_example_group_alias_globally'
from /home/shadowbq/sandbox/cartoque/spec/controllers/backup_exlusions_controller_spec.rb:3:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `load'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `each'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:102:in `setup'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
from /usr/local/rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.2.3/bin/rspec:23:in `load'
from /usr/local/rvm/gems/ruby-2.2.3/bin/rspec:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
More file snippets
root#ubuntu:/home/shadowbq/sandbox/cartoque# head -15 spec/controllers/backup_exlusions_controller_spec.rb
require 'spec_helper'
describe BackupExclusionsController do
login_user
before do
#backup_exclusion = BackupExclusion.create
end
it "gets index" do
get :index
assert_response :success
assert_not_nil assigns(:backup_exclusions)
end
https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
In rspec-rails 3, specs no longer have their type set automatically based on path, so your controller specs no longer have type :controller. You can either:
reneebable this with the config.infer_spec_type_from_file_location! option
explicitly tag your controller specs with type: :controller

Is activeuuid and rails 4.1.1 compatible or there is something wrong here?

Here is a little code snippet that I am trying to use to implement gem activeuuid:
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'activeuuid'
User.rb
class User < ActiveRecord::Base
include ActiveUUID::UUID
end
Migration xxxxxxxxx_create_users.rb
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users, :id => false do |t|
t.uuid :id, :primary_key => true
t.string :email
t.timestamps
end
end
def self.down
drop_table :users
end
end
Tyring a simple query is not proving to be fisible here even after bundle or restart of console ..
2.1.1 :016 > User.all
NoMethodError: undefined method `set_primary_key' for User (call 'User.connection' to establish a connection):Class
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activeuuid-ps-0.1.2/lib/activeuuid/uuid.rb:54:in `block in <module:UUID>'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `class_eval'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `append_features'
from /home/sahil/projects/test_projects/myapp/app/models/user.rb:3:in `include'
from /home/sahil/projects/test_projects/myapp/app/models/user.rb:3:in `<class:User>'
from /home/sahil/projects/test_projects/myapp/app/models/user.rb:1:in `<top (required)>'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `load'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `block in load_file'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:633:in `new_constants_in'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:442:in `load_file'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:342:in `require_or_load'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:480:in `load_missing_constant'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:180:in `const_missing'
from (irb):16
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
or even
2.1.1 :029 > User.count
NoMethodError: undefined method `set_primary_key' for User (call 'User.connection' to establish a connection):Class
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
from /home/sahil/.rvm/gems/ruby-2.1.1#myapp/gems/activeuuid-ps-0.1.2/lib/activeuuid/uuid.rb:54:in `block in <module:UUID>'
..........
..........
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Whats happening wrong here. Am i missing some required dependency.
Found out a better solution and implemented as show at : http://www.codesapling.com/blog/2014/05/24/using-uuid-as-primary-key-in-rails4-with-postgres/

Webbrick shuts down on its own

When I try to lauch webbrick from my terminal using rails server, This is what I get and webbrick shuts down, what could be the problem.
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
Following the shutdown I get this huge error which absolutely makes no sense to me.
/Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:229:in `default_controller_and_action': missing :controller (ArgumentError)
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:116:in `normalize_options!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:64:in `initialize'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1422:in `decomposed_match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1403:in `block in match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:601:in `map_method'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:562:in `get'
from /Users/Fulcrum/Sites/recrea8/config/routes.rb:14:in `block in <top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
from /Users/Fulcrum/Sites/recrea8/config/routes.rb:1:in `<top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Fulcrum/Sites/recrea8/config/environment.rb:5:in `<top (required)>'
from /Users/Fulcrum/Sites/recrea8/config.ru:3:in `require'
from /Users/Fulcrum/Sites/recrea8/config.ru:3:in `block in <main>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/Fulcrum/Sites/recrea8/config.ru:in `new'
from /Users/Fulcrum/Sites/recrea8/config.ru:in `<main>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
This is my route.rb
Recrea8::Application.routes.draw do
resources :sessions
resources :users
resources :categories
resources :characters
resources :industries
resources :nationalities
resources :personalities
resources :project_types
resources :projects
get 'logout', 'sessions#destroy', as: 'logout'
match ':controller(/:action(/:id))', :via => [:get, :post]
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'users#new'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Try to change lines:
#get 'logout', 'sessions#destroy', as: 'logout'
get 'logout' => 'sessions#destroy', as: 'logout'
And
#root 'users#new'
root to: 'users#new'

Resources