I'm trying to render partials in my view and it's breaking heroku, showing "We're sorry, but something went wrong".
It's been driving me mad. I think it's something to do with the asset pipeline, hopefully someone will know what I've done wrong.
Logs
2013-06-23T21:46:58.711440+00:00 app[web.1]:
> ActionView::Template::Error (Missing partial static_pages/gbgsynopsis,
> application/gbgsynopsis with {:locale=>[:en], :formats=>[:html],
> :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}.
> Searched in: 2013-06-23T21:46:58.711440+00:00 app[web.1]: *
> "/app/app/views" 2013-06-23T21:46:58.711440+00:00 app[web.1]: 19:
> <%= image_tag('GBG.jpg', class: "bookcover") %>
> 2013-06-23T21:46:58.711440+00:00 app[web.1]: 20:
> </div> 2013-06-23T21:46:58.711611+00:00 app[web.1]: 22:
> <%= render "gbgsynopsis" %> 2013-06-23T21:46:58.711611+00:00
> app[web.1]: app/views/static_pages/home.html.erb:22:in
> `_app_views_static_pages_home_html_erb__1233625768328599458_70301407659120' 2013-06-23T21:46:59.003669+00:00 heroku[router]: at=info method=GET
> path=/favicon.ico host=readerly.herokuapp.com fwd="86.156.197.140"
> dyno=web.1 connect=1ms service=4ms status=200 bytes=0
Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc2'
gem 'bootstrap-sass'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
View
<div class="row-fluid">
<div class="span4">
<%= image_tag('GBG.jpg', class: "bookcover") %>
</div>
<div class="span8">
<%= render "gbgsynopsis" %>
</div>
</div>
The following message is clear:
> ActionView::Template::Error (Missing partial static_pages/gbgsynopsis,
> application/gbgsynopsis with {:locale=>[:en], :formats=>[:html],
> :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}.
Rails can't find your partial. I guess it is in the wrong directory or has the wrong filename (e.g. missing the _ as a first character).
Have a look at http://xyzpub.com/en/ruby-on-rails/3.2/dynamische_webseiten.html#partials for some docu about partials.
Related
thanks for helping out.
My app works in localhost but I got below "unexpected token" error after deploying to Heroku. Also, I have the error regarding "favicon.ico" . Heroku log is as follow:
2022-05-02T05:47:55.619466+00:00 heroku[web.1]: Starting process with command `node app.js`
2022-05-02T05:47:56.000000+00:00 app[api]: Build succeeded
2022-05-02T05:47:57.053439+00:00 app[web.1]: /app/app.js:49
2022-05-02T05:47:57.053452+00:00 app[web.1]: return <div>
2022-05-02T05:47:57.053452+00:00 app[web.1]: ^
2022-05-02T05:47:57.053453+00:00 app[web.1]:
2022-05-02T05:47:57.053453+00:00 app[web.1]: SyntaxError: Unexpected token '<'
2022-05-02T05:47:57.053453+00:00 app[web.1]: at Object.compileFunction (node:vm:352:18)
2022-05-02T05:47:57.053454+00:00 app[web.1]: at wrapSafe (node:internal/modules/cjs/loader:1033:15)
2022-05-02T05:47:57.053455+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1069:27)
2022-05-02T05:47:57.053455+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
2022-05-02T05:47:57.053456+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-02T05:47:57.053456+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-02T05:47:57.053456+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
2022-05-02T05:47:57.053457+00:00 app[web.1]: at node:internal/main/run_main_module:17:47
2022-05-02T05:47:57.178016+00:00 heroku[web.1]: Process exited with status 1
2022-05-02T05:47:57.240533+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-02T05:48:51.164272+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-tundra-48558.herokuapp.com request_id=b06ff127-684c-407c-a44c-5f2b70ed2506 fwd="1.36.26.158" dyno= connect= service= status=503 bytes= protocol=https
2022-05-02T05:48:53.759984+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-tundra-48558.herokuapp.com request_id=2fd354ff-fc47-442b-812b-050147dd4c63 fwd="1.36.26.158" dyno= connect= service= status=503 bytes= protocol=https
Line 49 error in app.js is referring to below:
const Weather = () => {
return <div> <---- this line 49 with error
<div class="heading col-md-9">
<h5>Weather information for {weather.city}</h5>
<hr></hr>
</div>
<div className="welements col-md-9">
<div className="welement">
<strong>Weather :</strong> {weather.descp}
</div>
<div className="welement">
<strong>Temperature :</strong> {C.toFixed(2)} ℃
</div>
<div className="welement">
<strong>Humidity : </strong>{weather.humidity} %
</div>
<div className="welement">
<strong>Pressure :</strong> {weather.press} mb
</div>
</div>
</div>
}
have you created the Procfile?
if not then:
you need to do the following on your bash console
>cd <project directory>
>touch Procfile
>open Procfile
once you are in the procfile you need to add only single line in it
web: node app.js (or whatever is you index file)
after doing this, try again with the process
>git add .
>git commit -m "you message"
>git push heroku main
PS: also make sure your app.js is in the root directory
add a pair of ()
const Weather = () => {
return (<div>
<div class="heading col-md-9">
<h5>Weather information for {weather.city}</h5>
<hr></hr>
</div>
<div className="welements col-md-9">
<div className="welement">
<strong>Weather :</strong> {weather.descp}
</div>
<div className="welement">
<strong>Temperature :</strong> {C.toFixed(2)} ℃
</div>
<div className="welement">
<strong>Humidity : </strong>{weather.humidity} %
</div>
<div className="welement">
<strong>Pressure :</strong> {weather.press} mb
</div>
</div>
</div>);
}
The relevant code causing the problem seems to be this from my view:
<input type="checkbox" id=<%= "#{a[0]}#{ndx}" -%> class="toggle" />
<label for=<%= "#{a[0]}#{ndx}" -%> class="popup-label">
This throws the following error in the Heroku logs:
SyntaxError - /app/views/index.erb:25: syntax error, unexpected ')'
2017-03-17T06:30:26.877056+00:00 app[web.1]: ...buf.concat(( "#{a[0]}#{ndx}" -).to_s); #_out_buf.concat " cl...
2017-03-17T06:30:26.877061+00:00 app[web.1]: /app/views/index.erb:26: syntax error, unexpected ')'
2017-03-17T06:30:26.877057+00:00 app[web.1]: ... ^
2017-03-17T06:30:26.877061+00:00 app[web.1]: ...buf.concat(( "#{a[0]}#{ndx}" -).to_s); #_out_buf.concat " cl...
I initially thought it might be the difference between using WEBrick and Puma, but I swapped them and found no difference. Suggestions?
Please try the below
<input type="checkbox" id="<%= a[0].to_s + ndx.to_s %>" class="toggle" />
<label for="<%= a[0].to_s + ndx.to_s %>" class="popup-label">
When i run the test i receive this message(i am guessing it passed), but when i go to local host300 i receive the following on all my pages: No route matches [GET] "/about"
I have been stuck on this for around 4 hours :(
This is the test report i received-
C:\Sites\rails_projects\sample_app>bundle exec rspec spec/requests/static_pages_
spec.rb
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/ac
tive_support/dependencies.rb:251:in require': C:/Sites/rails_projects/sample_ap
p/app/helpers/application_helper.rb:12: syntax error, unexpected keyword_end, ex
pecting $end (SyntaxError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:251:inblock in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:236:in load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:359:in require_or_load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:313:independ_on'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:225:in require_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:135:inblock in modules_for_helpers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:131:in map!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:131:inmodules_for_helpers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/action_controller/metal/helpers.rb:92:in modules_for_helpers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:95:inhelper'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:159:in default_helper_module!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:22:inblock in inherited'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:22:in class_eval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/helpers.rb:22:ininherited'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/action_controller/metal/params_wrapper.rb:135:in inherited'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/abstract_controller/railties/routes_helpers.rb:7:inblock (2 levels) in
with'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2
.13/lib/action_controller/railties/paths.rb:7:in block (2 levels) in with'
from C:/Sites/rails_projects/sample_app/app/controllers/application_cont
roller.rb:1:in'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:251:in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:251:inblock in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:236:in load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:359:in require_or_load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:313:independ_on'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.13/lib/active_support/dependencies.rb:225:in require_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/engine.rb:439:inblock (2 levels) in eager_load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/engine.rb:438:in each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/engine.rb:438:inblock in eager_load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/engine.rb:436:in each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/engine.rb:436:ineager_load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/application/finisher.rb:53:in block in <module:Finisher>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/initializable.rb:30:ininstance_exec'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/initializable.rb:30:in run'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/initializable.rb:55:inblock in run_initializers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/initializable.rb:54:in each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/initializable.rb:54:inrun_initializers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/application.rb:136:in initialize!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from C:/Sites/rails_projects/sample_app/config/environment.rb:5:in <top
(required)>'
from C:/Sites/rails_projects/sample_app/spec/spec_helper.rb:3:inrequir
e'
from C:/Sites/rails_projects/sample_app/spec/spec_helper.rb:3:in <top (
required)>'
from C:/Sites/rails_projects/sample_app/spec/requests/static_pages_spec.
rb:1:inrequire'
from C:/Sites/rails_projects/sample_app/spec/requests/static_pages_spec.
rb:1:in <top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/configuration.rb:780:inload'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/configuration.rb:780:in block in load_spec_files'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/configuration.rb:780:inmap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/configuration.rb:780:in load_spec_files'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/command_line.rb:22:inrun'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/runner.rb:69:in run'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1
1.1/lib/rspec/core/runner.rb:8:inblock in autorun'
My Coded Pages:
helpers\application.helper.rb
def full_title(page_title)
base_title = "Ruby on Rails Tutorials Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
Static_pages_helper.rb
module StaticPagesHelper
end
Application.html.erb
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
Spec\requests\static_pages_spec.rb
require 'spec_helper'
describe "Static pages" do
subject { page }
describe "Home page" do
before { visit root_path }
it { should have_selector('h1', text: 'Sample App') }
it { should have_selector('title', text: full_title('')) }
it { should_not have_selector 'title', text: '| Home' }
end
describe "Help page" do
before { visit Help_path }
it { should have_selector('h1', text: 'Help') }
it { should have_selector('title', text: full_title('Help')) }
end
describe "About page" do
before { visit About_path }
it { should have_selector('h1', text: 'About') }
it { should have_selector('title', text: full_title('About Us')) }
end
describe "Contact page" do
before { visit Contact_path }
it { should have_selector('h1', text: 'Contact') }
it { should have_selector('title', text: full_title('Contact')) }
end
end
routes.rb
SampleApp::Application.routes.draw do
match '/static_pages/home' => 'static_pages#home'
match '/Help', to: 'static_pages#Help'
match '/About', to: 'static_pages#About'
match '/Contact', to: 'static_pages#Contact'
root to: 'static_pages#home'
about.html.erb
<% provide(:title, "About Us") %>
<h1>About Us</h1>
<p>
The Ruby on Rails Tutorial
is a project to make a book and screencasts to teach web development
with Ruby on Rails. This
is the sample application for the tutorial.
</p>
</body>
</html>
contact.html.erb
% provide(:title, 'Contact') %>
<h1>Contact</h1>
<p>
Contact Ruby on Rails Tutorial about the sample app at the
contact page.
</p>
help.html.erb
<% provide(:title, 'Help') %>
<!DOCTYPE html>
<html>
<head>
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
</head>
<body>
<h1>Help</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
Rails Tutorial help page
To get help on this sample app, see the
Rails Tutorial book.
</p>
</body>
</html>
home.html.erb
<div class="center hero-unit">
<h1>Welcome to the Sample App</h1>
<h2>
This is the home page for the
Ruby on Rails Tutorial
sample application.
</h2>
<%= link_to "Sign up now!", '#', class: "btn btn-large btn-primary" %>
</div>
<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
utilities.rb
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
application.rb
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module SampleApp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to
this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto
loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for
all models
# in your app. As such, your models will need to explicitly whitelist or blacklist
accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
github address:
https://github.com/froeal01/sample_app
Trying to starts the server, created with this error:
Exiting
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/ac
tive_support/dependencies.rb:245:in `load': C:/Sites/rails_projects/sample_app/c
onfig/routes.rb:64: syntax error, unexpected keyword_end, expecting $end (Syntax
Error)
Your application helper is missing an end.
def full_title(page_title)
base_title = "Ruby on Rails Tutorials Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
There's a problem with how you define your routes. Rails routes are all lowercase.
SampleApp::Application.routes.draw do
get "home", :to => "static_pages#home"
get "help", :to => "static_pages#help"
get "about", :to => "static_pages#about"
get "contacts", :to => "static_pages#contacts"
end
Therefore, your routes to the about page should be about_path instead.
THE ERROR:
Started GET "/users/invitation/new" for 127.0.0.1 at 2013-01-09 01:00:31 +0100
Processing by Devise::InvitationsController#new as HTML
User Load (451.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Rendered users/invitations/new.html.erb within layouts/application (69.2ms)
Rendered layouts/_google_analytics.html.erb (0.4ms)
Rendered layouts/_navbar.html.erb (73.6ms)
Completed 500 Internal Server Error in 10785ms
ActionView::Template::Error (No route matches {:controller=>"devise/dashboards", :action=>"show"}):
23: </ul>
24: <ul class="nav pull-right" id="main-menu-right">
25: <% if user_signed_in? %>
26: <li><%= link_to raw("My Agenda"), {:controller => :dashboards, :action => :show}, :tabindex => "-1" %></li>
27: <li><%= link_to raw("My Services"), {:controller => :creative_services, :action => :index_my_services}, :tabindex => "-1" %></li>
28: <li id="fat-menu" class="dropdown">
29: <a href="#" id="dropUser" role="button" class="dropdown-toggle" data-toggle="dropdown">
app/views/layouts/_navbar.html.erb:26:in `_app_views_layouts__navbar_html_erb__952134567516339951_70121556350080'
app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb___2663940439779075013_70121556359600'
On my Rails 3.1 project, I already use Devise.
I added devise_invitable gem in my Gemfile:
gem "devise", "~> 2.0.0"
gem 'devise_invitable', '~> 1.0.0'
Run these commands
rails generate devise_invitable:install
rails generate devise_invitable User
rake db:migrate
rails generate devise_invitable:views users
Set options in Devise.rb (Unlimited invitations
config.invitation_limit =
and start my server.
When I try to access /users/invitation/new
I am getting a routing error
Routing Error
No route matches {:controller=>"devise/dashboards", :action=>"show"}
In my User model:
devise :invitable, :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :invitable
My routes file:
devise_for :users, :controllers => { :registrations => 'registrations' }
How can I fix this routing issue?
workaround found here Routing error with devise {:controller=>"devise/static", :action=>"about"}
Changed my links:
26: <li><%= link_to raw("My Agenda"), {:controller => :dashboards, :action => :show}, :tabindex => "-1" %></li>
27: <li><%= link_to raw("My Services"), {:controller => :creative_services, :action => :index_my_services}, :tabindex => "-1" %></li>
to:
<li><%= link_to raw("My Agenda"), "/dashboards/show", :tabindex => "-1" %></li>
<li><%= link_to raw("My Services"), "/creative_services/index_my_services", :tabindex => "-1" %></li>
"and then all worked fine"
Ruby newbie here. I'm following the Rails Tutorial and got stuck around 5.3 re: routes.
I have 5 pages(home, about, help, contact), all with similar test set, and rspec is only failing for the tests on 'home'. Since I'm using application_helper, I shouldn't need to specify in home.html.erb, right? I also took the advise of understanding rails routes: match vs root in routes.rb and added "match '/static_pages/home' => 'static_pages#home'" to routes.db.
Been stuck on these 2 errors for a while. Please help. Thanks!
Errors:
1) Static pages Home page should have the h1 'Sample App'
Failure/Error: page.should have_selector('h1', text: 'Sample App')
expected css "h1" with text "Sample App" to return something
# ./spec/requests/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'
2) Static pages Home page should have the base title
Failure/Error: page.should have_selector('title',
expected css "title" with text "Ruby on Rails Tutorial Sample App" to return something
# ./spec/requests/static_pages_spec.rb:13:in `block (3 levels) in <top (required)>'
home.html.erb
<div class="center hero-unit">
<h1>Welcome to the Sample App</h1>
<h2>
This is the home page for the
Ruby on Rails Tutorial
sample application.
</h2>
<%= link_to "Sign up now!", '#', class: "btn btn-large btn-primary" %>
</div>
<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
static_pages_spec.rb
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the h1 'Sample App'" do
visit root_path
page.should have_selector('h1', text: 'Sample App')
end
it "should have the base title" do
visit root_path
page.should have_selector('title', text: "Ruby on Rails Tutorial Sample App")
end
it "should not have a custom page title" do
visit root_path
page.should_not have_selector('title', text: '| Home')
end
end
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
application_helper.rb
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title (page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
routes.rb
SampleApp::Application.routes.draw do
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
match '/static_pages/home' => 'static_pages#home'
root to: 'static_pages#home'
end
Let me know if you need anything else. Thanks!
Have you removed the public/index.html file and visually verified that you can get to / in your browser, and that the expected template is being rendered? Your spec looks OK otherwise.