ruby on rails - ActionView::MissingTemplate: ActionView::MissingTemplate: Missing template /members with {:locale=>[:en], :formats=>[:html], -


an integration test returning 'missing template' error. microposts_interface_test.rb errors on /members. may because /members view uses micropostscontroller i'm unsure how fix test.

error["test_micropost_interface", micropostsinterfacetest, 2015-06-19 06:40:32 +0800]  test_micropost_interface#micropostsinterfacetest (1434667232.75s) actionview::missingtemplate:         actionview::missingtemplate: missing template /members {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. searched in:           * "/home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates"           * "/home/me/development/my_app/app/views"           * "/home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/app/views"           * "/home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/phrasing-4.0.0rc9/app/views"              app/controllers/microposts_controller.rb:14:in `create'             test/integration/microposts_interface_test.rb:16:in `block (2 levels) in <class:micropostsinterfacetest>'             test/integration/microposts_interface_test.rb:15:in `block in <class:micropostsinterfacetest>'         app/controllers/microposts_controller.rb:14:in `create'         test/integration/microposts_interface_test.rb:16:in `block (2 levels) in <class:micropostsinterfacetest>'         test/integration/microposts_interface_test.rb:15:in `block in <class:micropostsinterfacetest>' 

micropostsinterfacetest:

require 'test_helper'  class micropostsinterfacetest < actiondispatch::integrationtest    def setup     @user = users(:michael)   end    test "micropost interface"     log_in_as(@user)     members_path     assert_select 'div.pagination'     assert_select 'input[type=file]'     # invalid submission     assert_no_difference 'micropost.count'       post microposts_path, micropost: { content: "" }     end     assert_select 'div#error_explanation'     # valid submission     content = "this micropost ties room together"     picture = fixture_file_upload('test/fixtures/rails.png', 'image/png')     assert_difference 'micropost.count', 1       post microposts_path, micropost: { content: content, picture: picture }     end     assert assigns(:micropost).picture?     assert_redirected_to root_url     follow_redirect!     assert_match content, response.body     # delete post.     assert_select 'a', text: 'delete'     first_micropost = @user.microposts.paginate(page: 1).first     assert_difference 'micropost.count', -1       delete micropost_path(first_micropost)     end     # visit different user.     user_path(users(:archer))     assert_select 'a', text: 'delete', count: 0   end    test "micropost sidebar count"     log_in_as(@user)     members_path     assert_match "#{@user.microposts.count} microposts", response.body     # user 0 microposts     other_user = users(:mallory)     log_in_as(other_user)     members_path     assert_match "0 microposts", response.body     # create micropost.     other_user.microposts.create!(content: "a micropost")     members_path     assert_match "1 micropost", response.body   end end 

update:

# controller/members_controller.rb  class memberscontroller < applicationcontroller     before_filter :logged_in_user   def index     @micropost = current_user.microposts.build     @feed_items = current_user.feed.paginate(page: params[:page])   end end 

i confirm there specific index view @ app/views/members/index.html.erb.

update 2:

# controller/microposts_controller.rb  class micropostscontroller < applicationcontroller   before_action :logged_in_user, only: [:create, :destroy]   before_action :correct_user,   only: :destroy    def create     @micropost = current_user.microposts.build(micropost_params)     if @micropost.save       flash[:success] = "micropost created!"       redirect_to members_path     else       @feed_items = []       render members_path     end   end    def destroy     @micropost.destroy     flash[:success] = "micropost deleted"     redirect_to request.referrer || members_path   end    private      def micropost_params       params.require(:micropost).permit(:content, :picture)     end      def correct_user       @micropost = current_user.microposts.find_by(id: params[:id])       redirect_to members_path if @micropost.nil?     end end 

in create action in micropostcontroller use render "members/index" instead of render members_path. note render not load variables needed in members/index, loads template add @micropost = [] did @feed_items = [] if calling variables view don't error of can't find variable @microposts. or can redirect_to members_path.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -