Heroku throws undefined method `devise_for' - ruby-on-rails

I have an app running local, and it works correctly. I've set up devise on it for OAuth with facebook.
When I push the app to Heroku I get this exception:
/app/app/controllers/users_controller.rb:2:in `<class:SessionsController>':
undefined method `devise_for'
for Users::SessionsController:Class (NoMethodError)
But I don't have this error locally.
These are the steps I took after pushing it to Heroku:
heroku run rake db:migrate
restarted heroku using heroku restart and heroku ps:restart
So the problem isn't that I still have to restart my server.
Here is my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# 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-rails'
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
What could be the issue?
Edit
Here are the first lines of where the error points at:
# app/controllers/users/users_controller
class Users::SessionsController < Devise::SessionsController
devise_for :users, :controllers => { :sessions => "users/sessions" }
end

Did you try running this locally? devise_for should be on your routes, not in the controller see https://github.com/plataformatec/devise to make sure you have your settings correctly. You don't need to override the controller, unless you are doing something special with it. If I where you I'll try to do the least amount of change first, and incrementally change it the way you want.

Related

RefineryCMS: routing error introduced by portfolio gallery plugin

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

Rails LoadError when trying to start server

I'm following SaaS from edX and I'm trying to run my rails server that I created using
rails s
and it keeps throwing a load error for
gem/ruby-1.9.3-p448/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so:
undefined symbol: ruby_current_thread
I'm not quite sure what I can do to fix this, or what other info would be required to help me solve this. I'm sorry for such a vague post but ruby on rails is rather new to me and I'm not sure why its throwing this
ive tried
gem install rails
and i get a permissions error
*Edit 1
Gemfile The debug19 is what i was told to put in per my instructions from edX 169.1
source 'https://rubygems.org'
gem 'rails', '3.2.14'
# 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', :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'
gem 'haml'
# To use debugger
# gem 'debugger'
group :development ,:test do
gem 'ruby-debug19' , :require => 'ruby-debug'
end
I don't know enough about your environment to give an exact answer, but you can try removing ruby-debug-base19 and ruby-debug from your Gemfile. You can also see if it's being installed by another gem by looking for references to them in your Gemfile.lock. If they are dependencies, remove the gems they depend on as well.

Integrating refinerycms into existing rails app

I am trying to integrate refinerycms with my existing rails application(my app uses devise).
Followed this tutorial and got this error when run the command rails g refinery:cms --fresh-installation
== AddSourceUrlToBlogPosts: migrating ========================================
rake aborted!
An error has occurred, this and all later migrations canceled:
uninitialized constant Refinery::User/home/sunloverz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/home/sunloverz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in `each'
My gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3'
end
# 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-rails', '~> 2.3.0'
gem "devise", "~> 2.2.3"
gem "refinerycms-core", "~> 2.1.0"
gem "refinerycms-dashboard", "~> 2.1.0"
gem "refinerycms-images", "~> 2.1.0"
gem "refinerycms-pages", "~> 2.1.0"
gem "refinerycms-resources", "~> 2.1.0"
gem 'refinerycms-blog', :git => 'git#github.com:refinery/refinerycms-blog.git', :branch => 'master'
There is an official guide for the exact environment that you describe:
Using Refinery with Rails 3.1 and Devise
It doesn't even assume you have already the app working. The guide goes from creating the app and adding Devise to installing Refinery on top of that.

Bootstrap and Rails issue with Heroku Deployment

Im making a Ruby on Rails app. I've included the twitter-bootstrap rails gem. Having tested the app locally, I've attempted numerous times to deploy to Heroku. I first encountered this 500 error:
ActionView::Template::Error (images/apple-touch-icon-144x144-precomposed.png isn't precompiled)
I solved this initial problem, by adding this line to the config/environment/production.rb file.
config.assets.compile = true
Now, I'm trying to push my rails app to Heroku again but when I push to Heroku I'm getting this 500 error again. I have no idea how to solve this one:
ActionView::Template::Error (undefined local variable or method `bootstrap_flash' for#<#
77: </div><!--/span-->
79: <%= bootstrap_flash %>
78: <div class="span9">
80: <%= yield %>
app/views/layouts/application.html.erb:79:in `_app_views_layouts_application_html_erb___2619453860724409461_34912060'
81: </div>
82: </div>
Any help would be greatly appreciated!
This is my Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'devise'
# 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'
gem "therubyracer"
gem "less-rails"
gem 'twitter-bootstrap-rails', :git => 'http://github.com/seyhunak/twitter-bootstrap-rails.git'
end
gem 'jquery-rails'
I've tried rake assets:precompile and then upload to Heroku but still, no luck.
You seems to be having this previously reported issue. Try adding the following gem:
gem 'bootstrap_helper'
You can also add this File, as one of your helpers. That's what fixed for most of the folks on that thread.

Rails: undefined method 'paginates_per'

I'm installing a gem called Carrier https://github.com/stanislaw/carrier/blob/master/Gemfile into a Rails 3.2.1 app. It uses Kaminari and when I did bundle install after adding gem "carrier" to my Gemfile, it showed that I was using kaminari
Using kaminari (0.13.0)
However, when I tried to rake db:migrate, I got this error
rake aborted
undefined method `paginates_per' for Carrier::Chain(Table doesn't exist):Class
Can anyone suggest a fix for this? I've copied the gemfile from the Carrier gem below and the Gemfile for my own app below that
(Carrier gem Gemfile)
source "http://rubygems.org"
gem 'require_all'
gem 'kaminari'
gem 'unread'
gem 'sugar-high'
gem 'sweetloader'
group :development, :test do
gem 'rails', '~> 3.1.0'
gem 'unicorn'
gem 'mysql2'
gem 'devise'
gem 'rake-kit'
gem 'cutter'
gem "jeweler", ">= 1.6.4"
gem "rspec-rails", '>= 2.5'
end
group :test do
gem 'capybara'
gem 'factory_girl'
gem 'spork'
gem "launchy"
gem 'shoulda'
end
Gemfile for my starter app
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'devise'
gem 'carrier'
# 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'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
Update These are the migrations it installed when I ran install:migrations
rake carrier:install:migrations
Copied migration 20120229055640_create_messages.carrier.rb from carrier
Copied migration 20120229055641_create_chains.carrier.rb from carrier
Update
I tried to reinstall it again on another git branch it this time I got a slightly different error when I ran rake db:migrate
rake aborted!
undefined method `acts_as_readable' for Carrier::Message(Table doesn't exist):Class
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
You appear to be missing some database backing for what Carrier is trying to do. From the Carrier readme, it looks like you need to run rake carrier:install:migrations before running db:migrate. Have you done that?

Resources