I'm a newbie trying to learn ruby on rails. I'm following the One Month Rails course and I'm currently stuck on getting my app to display on Heroku. The demo displays locally when I type localhost:3000, but when I try to deploy to app on Heroku it gives me a screen that says "The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved."
My gem file looks like this:
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.0.0'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'heroku'
group :doc do
gem 'sdoc', require: false
end
I looked around and tried various solutions and none of them worked for this.
routes.rb file:
Omrails::Application.routes.draw do
get "pages/index"
root 'pages#home'
Sounds like you didn't root a page yet.
You have to root as page for heroku to land there.
Put this in
root 'pages#index'
That should work
Hope it helps
And take out
get 'pages...'
root 'pages#home'
Related
I've tried all the methods outlined Here for getting google analytics up and running on my rails app.
I think that google is talking to my app because when I inspect the elements and look at the network I see the .js file.
I thought I might need to just sit and wait but this didn't work. I've now tried several ways to do this and nothing is working.
gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.11'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# For google analytics
gem 'google-analytics-rails', '1.0.0'
gem 'activeadmin'
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
group :development do
gem 'pry'
end
gem 'rails_12factor'
gem 'delayed_job_active_record'
gem 'unicorn'
I have this line in my head tag at the bottom.
<%= analytics_init if Rails.env.production? %>
I thought this was the problem so I removed the if statement but that seemed like a bad idea as it would allow google to track any environment.It still didn't work after this...
What am I missing? I've never had this problem with analytics before. Any suggestions?
My guess is that you forgot to replace the placeholder within the analytics.js.coffee file.
#analyticsId: ->
# your google analytics ID(s) here...
'UA-XXXXXXX-XX'
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 have installed ActiveAdmin and Devise, but when i trye to log in as User, it displays wrong CSS styling. have tryed many times, it still the same..
When i go to localhost:3000/admin -> it displays good looking Login form.
When i go to localhost:3000/users/sign_in -> it displays bad looking Login form, inherited from ActiveAdmin Login form.
I installed them like this:
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'ransack', github: 'activerecord-hakery/ransack'
gem 'devise'
$bundle install
$rails g devise:install
$rails g active_admin:install
$rails g devise user
$rake db:migrate
I've tryed many different ways, looked up in internet but all information is so old.. and my stylings of devise sign in and sign up is really wrong..
This is my GemFile
source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'sqlite3'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'ransack', github: 'activerecord-hackery/ransack'
gem 'devise'
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 'tzinfo-data', platforms: [:mingw, :mswin]
I'm not at home and I don't have access to my PC so I am not able to give you 100% answers(name of the files etc..) however I had the same problem and I solved the same issue by putting the stylesheet of activeadmin into the vendors directory.
I've built a model called "Subject" in my Rails 3.2 application. I used the scaffold command below.
rails g scaffold Subject subject singular:boolean gender:integer subject_masculine subject_feminine subject_neuter language:references --skip-stylesheets
The scaffold runs almost to the end, but then gives a mysterious error about the helper:
The name 'SubjectsHelper' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.
I've tried reversing the scaffold and rebuilding. In the end I just built the table and it seems to be working ok. There is no helpers/subjects_helper.rb file, but I don't expect to need a helper for this particular model.
I could not find subject among any reserved word list, but that in itself was a problem. Another SO post has been raised on this issue.
List of reserved words in rails *3*
Why am I getting this error, and can I just ignore it?
EDIT
My Gemfile as requested
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'thin'
gem 'sinatra'
gem 'pg'
gem 'simple_form'
gem "nested_form"
gem 'thinking-sphinx'
gem 'devise'
gem 'haml-rails'
gem 'ruby_parser'
gem 'html2haml'
gem 'best_in_place'
gem 'carrierwave'
gem 'fog'
gem 'seed_dump'
gem 'bluecloth'
gem 'redcarpet'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'prototype-rails'
gem 'uglifier', '>= 1.0.3'
gem 'twitter-bootstrap-rails'
gem 'therubyracer'
gem 'less-rails'
gem 'jquery-datatables-rails'
end
gem 'jquery-rails'
gem 'social_stream'
gem 'rails-footnotes', '>= 3.7.5.rc4', :group => :development
group :development do
gem 'rails-erd'
gem 'quiet_assets'
end
gem 'vestal_versions', :git => "git://github.com/futurechimp/vestal_versions.git"
gem 'diffy'
gem 'diffrent'
EDIT2
As per Philip's suggestion, I ran the Module.constants command from the Rails console. Amongst the output, there were two 'subject' values:
:SubjectsHelper
:Subject
I check several times there is no helper, so I decided to add one. I created the helpers/subjects_helper.rb file, with the following code:
module SubjectsHelper
end
Rails has now rebooted OK. I still don't understand what happened though.
As you correctly say, SubjectsHelper is already provided by Social Stream. See:
https://github.com/ging/social_stream/blob/master/base/app/helpers/subjects_helper.rb
Your solution is working because you are reopening the module, which is a valid action in Ruby.
I found it. I am using the Social Stream gem, which has a subject in the routes.
subject_lrdd /subjects/lrdd/:id(.:format)
It must be buried in the engine somewhere.
I've been self-learning developing rails plugin.
One referenced tutorial I'm using is here.
Unfortunately, it seemed I got stuck since the first step when I run "rails generate plugin. It's returning an error saying "rspec [not found]".
c:\rails\test\rails generate plugin HelloWorld
create vendor/plugins/hello_world
create vendor/plugins/hello_world/MIT-LICENSE
create vendor/plugins/hello_world/README
create vendor/plugins/hello_world/Rakefile
create vendor/plugins/hello_world/init.rb
create vendor/plugins/hello_world/install.rb
create vendor/plugins/hello_world/uninstall.rb
create vendor/plugins/hello_world/lib
create vendor/plugins/hello_world/lib/hello_world.rb
error rspec [not found]
I tried to look for possible solutions myself. One that I tried was making an update of the project's bundler gem in hope that might come from a bug of plugin compatibility.
anyway, just in case it would help give you guys some clue on where it could go wrong, I also post my GemFile as follows.
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'annotate', ">=2.5.0"
gem 'sqlite3'
gem 'faker', '0.3.1'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
gem 'jquery-rails'
gem 'pg', '0.14.0'
gem 'bundler', '1.2.0.rc.2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'rspec-rails', '2.6.1'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
gem 'factory_girl_rails', '1.0'
end
Any advice would be really appreciated!
I think it's trying to generate template rspec examples for the plugin, but the rspec directory isn't there. Did you run the rspec installer (rails g rspec:install) after adding rspec to your Gemfile?