New to Ruby on Rails, would appreciate if someone could help point me in the right direction. Thanks
Finished tests in 0.627036s, 38.2753 tests/s, 74.9558 assertions/s.
1) Error:
CartsControllerTest#test_should_destroy_cart:
ActionView::MissingTemplate: Missing template carts/destroy, application/destroy
with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "c:/Users/Daniel Huang/My Documents/projects/trying-again/depot/app/views"
app/controllers/carts_controller.rb:85:in `set_cart'
test/controllers/carts_controller_test.rb:45:in `block (2 levels) in <class:
CartsControllerTest>'
test/controllers/carts_controller_test.rb:43:in `block in <class:CartsControllerTest>'
2) Error:
CartsControllerTest#test_should_update_cart:
ActionView::MissingTemplate: Missing template carts/update, application/update w
ith {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby,
:jbuilder, :coffee]}. Searched in:
* "c:/Users/Daniel Huang/My Documents/projects/trying-again/depot/app/views"
app/controllers/carts_controller.rb:85:in `set_cart'
test/controllers/carts_controller_test.rb:38:in `block in <class:CartsControllerTest>'
3) Error:
LineItemsControllerTest#test_should_create_line_item:
AbstractController::ActionNotFound: The action 'create' could not be found for L
ineItemsController
test/controllers/line_items_controller_test.rb:21:in `block (2 levels) in <class:LineItemsControllerTest>'
test/controllers/line_items_controller_test.rb:20:in `block in <class:LineIt
emsControllerTest>'
4) Error:
LineItemsControllerTest#test_should_destroy_line_item:
AbstractController::ActionNotFound: The action 'destroy' could not be found for
LineItemsController
test/controllers/line_items_controller_test.rb:44:in `block (2 levels) in class:LineItemsControllerTest>'
test/controllers/line_items_controller_test.rb:43:in `block in <class:LineItemsControllerTest>'
5) Error:
LineItemsControllerTest#test_should_get_new:
ActionView::Template::Error: First argument in form cannot contain nil or be empty
app/views/line_items/_form.html.erb:1:in_app_views_line_items__form_html_erb___607916578_29103084'
app/views/line_items/new.html.erb:3:in `_app_views_line_items_new_html_erb__
_811078298_42530004'
test/controllers/line_items_controller_test.rb:15:in `block in <class:LineIt
emsControllerTest>'
6) Error:
LineItemsControllerTest#test_should_update_line_item:
ActionController::ParameterMissing: param not found: line_item
app/controllers/line_items_controller.rb:89:in `line_item_params'
app/controllers/line_items_controller.rb:59:in `block in update'
app/controllers/line_items_controller.rb:58:in `update'
test/controllers/line_items_controller_test.rb:38:in `block in<class:LineItemsControllerTest>'
24 tests, 47 assertions, 0 failures, 6 errors, 0 skips
c:\Users\Daniel Huang\My Documents\projects\trying-again\depot>
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 am trying to use teaspoon with Jasmine suite to test my AngularJS scripts in Ruby on Rails. While running "rake teaspoon", I am getting the below error -
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:41029/specs/default
Fontconfig error: Cannot load default config file
Error: ActionView::MissingTemplate: Missing template teaspoon/suite/show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}. Searched in:
Any pointers?
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
I have a very simple rails controller test that behaves differently depending on how it is run:
When I run it using:
RAILS_ENV=test ruby -Itest test/controllers/news_controller_test.rb the test passes fine (I used RAILS_ENV to try and make it as similar to rake test as I can.
When run using rake test, the test fails with:
12) Error: NewsController::admin#test_0003_creates a new news post:
ActionView::MissingTemplate: Missing template news/create,
application/create with {:locale=>[:en], :formats=>[:html],
:variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :slim,
:jbuilder, :coffee]}. Searched in: *
"/home/emery/eop/portal/app/views" *
"/home/emery/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/kaminari-0.15.1/app/views"
test/controllers/news_controller_test.rb:73:in `block (4 levels) in <top (required)>'
test/controllers/news_controller_test.rb:72:in `block (3 levels) in <top (required)>'
This is only one specific case where a test fails under rake test but passes with ruby -Itest ... There are many others that behave this way. Some, like this one, are missing templates which they shouldn't need, others are returning success when they should be redirecting the user, and others are more esoteric. Which is why my question is more general, what are the key differences between rake test and RAILS_ENV ruby -Itest ...? I'd like to be able to debug these myself.
My stack is Rails 4.1rc1, using minitest-spec-rails (master branch).
For completeness, here is the test and controller code for the error above:
The controller action is pretty simple:
def create
#news = News.new(safe_params)
if #news.save
redirect_to news_index_path
else
render :new
end
end
The code either redirects or renders the new template, so it's true that news/create doesn't exist, but it shouldn't be needed.
The controller test code is:
let(:editor) { User.create! first_name: 'Malcom', last_name: 'Reynolds', email: 'captain#firefly.com', password: 'hmm' }
before do
subject.login editor
end
...
it 'creates a new news post' do
assert_difference 'News.count', 1 do
post :create, news: { subject: 'abcd', body: 'rst' }
end
assert_redirected_to news_index_path
end
(subject.login is a custom login function on the application controller)
It turned out to be an issue with one of my other controller test cases. I had one controller test that mocked a few calls out, but those mocks were inadvertently permanent, changing the application controller. This broke the remaining controller test cases in different ways.
So the key difference in this case was that running rake test runs all the test cases, and ruby -Itest only runs one test.
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