I have a plugin (in my_rails_app/vendor/plugins directory) and its controllers use view from my application (my_rails_app/app/views). When I run it in development mode everything works well, but in staging/production it seems like the plugin looks for partial views in its own directory (my_rails_app/vendor/plugins/my_plugin/app/views).
For example I have controller (in the plugin):
module MyPlugin
class SampleController < ApplicationController
layout "application"
def new
#code
end
end
end
The layout is OK in both development and production, but the layout's in the template itself, I render a partial:
= render :partial => "_head"
in development: works well
in production:
ActionView::Template::Error (Missing partial /sample/head, stamper/application/head with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
* "/my_rails_app/app/views"
* "/my_rails_app/vendor/plugins/my_plugin/app/views"
Why production plugin looks for a different path?
Related
For convenience let's say we run the following:
bin/rails generate scaffold Candidate::Test
The generating function then proceeds to generate all the major components on the corresponding module names. Everything should work fine if I do a rails test right after generating the scaffold but I get the following error.
Candidate::TestsControllerTest#test_should_show_candidate_test:
RuntimeError: Neutered Exception ActionView::Template::Error: Missing partial candidate/tests/_test with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}.
And here's what the error suggested:
Did you mean? candidate/tests/candidate_test
There's something wrong with the naming of the generator. What should I do to resolve this?
You read link https://guides.rubyonrails.org/v5.1/generators.html
Rails: 7.0.3
Ruby: 3.1.2
And I run bin/rails generate scaffold Candidate::Test => It's okie.
I forked a gem and changed some things, but I am really desperate. I always get Template is missing:
Template is missing
Missing template spree/addresses/index, spree/store/index, spree/base/index, application/index with {:locale=>[:de, :en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :haml, :rabl], :versions=>[:v1]}. Searched in: * "/Users/Manu/Documents/rails_projects/my_store_dev/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_my_favourites-6076d6ee5cb2/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_address_book-b66e2abf6429/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-promotion-roles-rule-0fd33e96c5c4/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-promotion-exclude-specials-rule-1debc9765387/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_better_terms_and_conditions-8001a85040eb/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/gems/spree_quick_cart-2.2.3/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_i18n-1d94e07c68c7/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_auth_devise-01901766a256/lib/views/backend" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_auth_devise-01901766a256/lib/views/frontend" * "/Users/Manu/.rvm/gems/ruby-2.1.2/gems/devise-3.2.4/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree_gateway-5cbe3890d1a0/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-33c8fa4d51d8/frontend/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-33c8fa4d51d8/backend/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-33c8fa4d51d8/api/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/bundler/gems/spree-33c8fa4d51d8/core/app/views" * "/Users/Manu/.rvm/gems/ruby-2.1.2/gems/kaminari-0.15.1/app/views"
This is my routes file:
Spree::Core::Engine.routes.draw do
# Add your extension routes here
namespace :account do
resources :orders, only: [:index]
resources :favourites, only: [:index]
resources :addresses, only: [:index]
end
end
This is my AddressesController in controller/spree/account/:
module Spree
module Account
class AddressesController < Spree::StoreController
before_filter :check_logged_in_user
def index
#user = try_spree_current_user
end
private
def check_logged_in_user
unless try_spree_current_user
account_addresses__path
redirect_to spree_login_path
end
end
end
end
end
I have a index.haml in views/spree/account/addresses/, and this is part of rake routes:
account_orders GET /account/orders(.:format) spree/account/orders#index
account_favourites GET /account/favourites(.:format) spree/account/favourites#index
account_addresses GET /account/addresses(.:format) spree/account/addresses#index
Can someone please give me a hint?
I had an similar experience, not sure if this applies to you or not but here it is:
This is the error I got:
ActionView::MissingTemplate at / .
Missing partial spree/shared/_google_analytics with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :haml, :jbuilder, :rabl], :versions=>[:v1]}. Searched in:
* "/Users/sjones/work/cs-spree/app/views"...
But it turns out the partial actually exists and is even being parsed and run (I use the RubyMine debugger to check)
The error is incorrect. In my case a helper method try_spree_current_user was missing from the controller, and this missing method NoMethodError error was somehow being trapped and replaced with the MissingTemplate error shown.
Fixing that error caused the template to load just fine.
Like I said, this may not be your problem, but this is so weird I'm posting this for others.
I was getting this error after installing extension spree_theme
Missing partial spree/shared/_google_analytics
i ended up finding the file (so it was not missing at all) here: public/vinsol_spree_themes/current/views/spree/shared/_google_analytics.js.erb
after debugging a bit finally detected a missing class of class not defined type error with something Spree::Tracker so all i had to was to fix that dependency and the thing worked, as mentioned above by stujo sometimes it seems this message is not related with the file itself but with external causes
this is how i'm generating my project from scratch if you proceed this way you will probably dont have any more issues and will be able to run spree 3.5 just fine
Spree base installation from scratch
** Assuming you have an empty rails app **
Update Gemfile
gem 'spree', '~> 3.5.0'
gem 'spree_auth_devise', '~> 3.3'
gem 'spree_gateway', '~> 3.3'
Install development dependencies
1) bundle update i18n (i'm thinking this is optional but not sure)
2) bundle install
Install install generators to set up Spree:
1) rails g spree:install --user_class=Spree::User
You will be asked to setup an admin account
Email [spree#example.com]: admin#cucg.com
Password [spree123]:
then just run rails s and you will be all set
I just followed this Spree Official Installation Guide and everything worked jut fine
You need to include html to your haml file name.
Like so:
your_file_name.html.haml
Rename your index file to:
index.html.haml
Read more about haml here:
http://haml.info/tutorial.html
Getting this error in my heroku log after pushing. I didn't attempt to configure postgres so I would imagine it would complain about that [I am not using a database at all in this application though, I am folloiwng Michael Hartls tutorial, building the sample app.
ActionView::Template::Error (Missing partial layouts/shim with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
...
this is the github, however, I am kind of confused. I could have sworn I modified controllers more recently than 3 days ago.
https://github.com/lilsheep/sample_app
The entire error log is here:
http://pastebin.com/ZB2av82g
In application.html.erb layout you refer to shim.html.erb via
<%= render 'layouts/shim' %>
But there is no such file in layouts folder
I am using rails version 3.2.12 and was using .erb templates for my view.
Now I want to start using haml templates.
I added haml and haml-rails to the gem file and installed the bundle.
Using haml (4.0.0)
Installing haml-rails (0.4)
I have made a mock-up application.html.haml
!!! 5
%html
%head
%title Rotten Potatoes!
= stylesheet_link_tag 'application'
= javascript_include_tag 'application'
= csrf_meta_tags
%body
= yield
I then changed the application_controller.rb to
class ApplicationController < ActionController::Base
layout "application"
protect_from_forgery
include SessionsHelper
end
when I run this I get the following error message:
Missing template layouts/application with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/home/coen/Desktop/rails_project/sample_app/app/views"
it seems as if the haml handler not installed.
How can I accomplish this?
Well, have you restarted your development server? It is very important thing to do after adding a gem to Gemfile.
BTW. I use haml all the time, i haven't ever used 'haml-rails'.
When i start fresh project, the only thing i do is add "gem 'haml'" to Gemfile and everything works just like it supposed to work.
My app works on my local machine, but won't work on the production server.
Using capistrano, everything is up and running under /var/www/current.
Restarted web server.
Getting the site's custom 404, but can't even retrieve stuff out of /public/images using the direct link.
Getting this in the log:
ActionView::MissingTemplate (Missing template access/index with {:locale=>[:en, :en], :handlers=>[:rxml, :builder, :erb, :rjs, :rhtml], :formats=>[:html]} in view paths "/var/www/releases/20110703002055/app/views", "/var/www/shared/bundle/ruby/1.8/gems/kaminari-0.12.4/app/views"):
I've been playing with routes.rb - here is the only line from it right now:
root :to => 'access#index', :as => 'access'
I do have these in access_controller.rb:
def index
end
def welcome
respond_to do |format|
format.html # welcome.html.erb
end
end
I have a template index.html.erb and welcome.html.erb in the app/views/access directory.
I don't really know capistrano, but if you are using Git or something like that to push your code to your server, it looks like you have not added all the files to your repository. (it whines over not finding access/index.html.erb)
In git it's like:
git add .
git commit -m "adding missing files"