Template is missing in Ruby on Rails using Active admin












3















I have an error in my project where in active admin it keeps on telling me missing template. Help on what to do what I want to happen is to be able to add a staff user in active admin




Missing template admin/vendor/update_add_staff,
active_admin/resource/update_add_staff,
active_admin/base/update_add_staff,
inherited_resources/base/update_add_staff, application/update_add_cat
with {:locale=>[:en], :formats=>[:html], :variants=>,
:handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder,
:slim, :csvbuilder]}. Searched in:
/Users/James/work-files/apps/views "/Users/james/.gem/gems/devise-4.0.3/app/views" *
"/Users/james/.gem/bundler/gems/apipie-rails-1f7d8419b7f4/app/views" *
"/Users/james/.gem/bundler/gems/activeadmin-09d00c2d9638/app/views" *
"/Users/james/.gem/gems/kaminari-core-1.1.1/app/views"




Below is the codes:



Starting from admin/vendor.rb



the button "add" connects to the action item:



  action_item :edit_add_staff, only: [:show, :edit] do
link_to('Add cat', edit_add_staff_admin_vendor_path(resource))
end


then the action item connects to :



<%= simple_form_for([:admin, resource], url: update_add_staff_admin_vendor_path(resource), method: :put) do |f| %>
<div class="input text optional">
<label for="vendor_staff_users">Current Staff List</label>
<div class="indent-display">
<% resource.staff_users.each do |staff| %>
ID: <%= staff.id %> | <%= staff.full_name %> <br/>
<% end %>
</div>
</div>

<div class="input optional">
<label class="optional" for="vendor_staff_users">Staff ID</label>
<%= text_field_tag('vendor[staff_user]') %>
<span class="hint">Hint: Enter the staff user id</span>
</div>

<%= f.submit 'Add Staff' %>

<% end %>


then it is linked to:



member_action :update_add_staff, method: :put do
u = User.find(params[:vendor][:staff_user])
if u.staff_user == false
u.staff_user = true
u.vendor_id = id
binding.pry
u.save
redirect_to admin_vendor_path(resource)
end
end


and this is the routes:



 resources :vendors, only: [:show, :update] do
resources :users, controller: 'vendors/vendor_users' do
member do
post :update_add_staff


I hope someone can help me I don't really know what to do










share|improve this question

























  • If u.staff_user != false, your action will not perform redirect

    – Pavel Oganesyan
    Nov 23 '18 at 10:44
















3















I have an error in my project where in active admin it keeps on telling me missing template. Help on what to do what I want to happen is to be able to add a staff user in active admin




Missing template admin/vendor/update_add_staff,
active_admin/resource/update_add_staff,
active_admin/base/update_add_staff,
inherited_resources/base/update_add_staff, application/update_add_cat
with {:locale=>[:en], :formats=>[:html], :variants=>,
:handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder,
:slim, :csvbuilder]}. Searched in:
/Users/James/work-files/apps/views "/Users/james/.gem/gems/devise-4.0.3/app/views" *
"/Users/james/.gem/bundler/gems/apipie-rails-1f7d8419b7f4/app/views" *
"/Users/james/.gem/bundler/gems/activeadmin-09d00c2d9638/app/views" *
"/Users/james/.gem/gems/kaminari-core-1.1.1/app/views"




Below is the codes:



Starting from admin/vendor.rb



the button "add" connects to the action item:



  action_item :edit_add_staff, only: [:show, :edit] do
link_to('Add cat', edit_add_staff_admin_vendor_path(resource))
end


then the action item connects to :



<%= simple_form_for([:admin, resource], url: update_add_staff_admin_vendor_path(resource), method: :put) do |f| %>
<div class="input text optional">
<label for="vendor_staff_users">Current Staff List</label>
<div class="indent-display">
<% resource.staff_users.each do |staff| %>
ID: <%= staff.id %> | <%= staff.full_name %> <br/>
<% end %>
</div>
</div>

<div class="input optional">
<label class="optional" for="vendor_staff_users">Staff ID</label>
<%= text_field_tag('vendor[staff_user]') %>
<span class="hint">Hint: Enter the staff user id</span>
</div>

<%= f.submit 'Add Staff' %>

<% end %>


then it is linked to:



member_action :update_add_staff, method: :put do
u = User.find(params[:vendor][:staff_user])
if u.staff_user == false
u.staff_user = true
u.vendor_id = id
binding.pry
u.save
redirect_to admin_vendor_path(resource)
end
end


and this is the routes:



 resources :vendors, only: [:show, :update] do
resources :users, controller: 'vendors/vendor_users' do
member do
post :update_add_staff


I hope someone can help me I don't really know what to do










share|improve this question

























  • If u.staff_user != false, your action will not perform redirect

    – Pavel Oganesyan
    Nov 23 '18 at 10:44














3












3








3








I have an error in my project where in active admin it keeps on telling me missing template. Help on what to do what I want to happen is to be able to add a staff user in active admin




Missing template admin/vendor/update_add_staff,
active_admin/resource/update_add_staff,
active_admin/base/update_add_staff,
inherited_resources/base/update_add_staff, application/update_add_cat
with {:locale=>[:en], :formats=>[:html], :variants=>,
:handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder,
:slim, :csvbuilder]}. Searched in:
/Users/James/work-files/apps/views "/Users/james/.gem/gems/devise-4.0.3/app/views" *
"/Users/james/.gem/bundler/gems/apipie-rails-1f7d8419b7f4/app/views" *
"/Users/james/.gem/bundler/gems/activeadmin-09d00c2d9638/app/views" *
"/Users/james/.gem/gems/kaminari-core-1.1.1/app/views"




Below is the codes:



Starting from admin/vendor.rb



the button "add" connects to the action item:



  action_item :edit_add_staff, only: [:show, :edit] do
link_to('Add cat', edit_add_staff_admin_vendor_path(resource))
end


then the action item connects to :



<%= simple_form_for([:admin, resource], url: update_add_staff_admin_vendor_path(resource), method: :put) do |f| %>
<div class="input text optional">
<label for="vendor_staff_users">Current Staff List</label>
<div class="indent-display">
<% resource.staff_users.each do |staff| %>
ID: <%= staff.id %> | <%= staff.full_name %> <br/>
<% end %>
</div>
</div>

<div class="input optional">
<label class="optional" for="vendor_staff_users">Staff ID</label>
<%= text_field_tag('vendor[staff_user]') %>
<span class="hint">Hint: Enter the staff user id</span>
</div>

<%= f.submit 'Add Staff' %>

<% end %>


then it is linked to:



member_action :update_add_staff, method: :put do
u = User.find(params[:vendor][:staff_user])
if u.staff_user == false
u.staff_user = true
u.vendor_id = id
binding.pry
u.save
redirect_to admin_vendor_path(resource)
end
end


and this is the routes:



 resources :vendors, only: [:show, :update] do
resources :users, controller: 'vendors/vendor_users' do
member do
post :update_add_staff


I hope someone can help me I don't really know what to do










share|improve this question
















I have an error in my project where in active admin it keeps on telling me missing template. Help on what to do what I want to happen is to be able to add a staff user in active admin




Missing template admin/vendor/update_add_staff,
active_admin/resource/update_add_staff,
active_admin/base/update_add_staff,
inherited_resources/base/update_add_staff, application/update_add_cat
with {:locale=>[:en], :formats=>[:html], :variants=>,
:handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder,
:slim, :csvbuilder]}. Searched in:
/Users/James/work-files/apps/views "/Users/james/.gem/gems/devise-4.0.3/app/views" *
"/Users/james/.gem/bundler/gems/apipie-rails-1f7d8419b7f4/app/views" *
"/Users/james/.gem/bundler/gems/activeadmin-09d00c2d9638/app/views" *
"/Users/james/.gem/gems/kaminari-core-1.1.1/app/views"




Below is the codes:



Starting from admin/vendor.rb



the button "add" connects to the action item:



  action_item :edit_add_staff, only: [:show, :edit] do
link_to('Add cat', edit_add_staff_admin_vendor_path(resource))
end


then the action item connects to :



<%= simple_form_for([:admin, resource], url: update_add_staff_admin_vendor_path(resource), method: :put) do |f| %>
<div class="input text optional">
<label for="vendor_staff_users">Current Staff List</label>
<div class="indent-display">
<% resource.staff_users.each do |staff| %>
ID: <%= staff.id %> | <%= staff.full_name %> <br/>
<% end %>
</div>
</div>

<div class="input optional">
<label class="optional" for="vendor_staff_users">Staff ID</label>
<%= text_field_tag('vendor[staff_user]') %>
<span class="hint">Hint: Enter the staff user id</span>
</div>

<%= f.submit 'Add Staff' %>

<% end %>


then it is linked to:



member_action :update_add_staff, method: :put do
u = User.find(params[:vendor][:staff_user])
if u.staff_user == false
u.staff_user = true
u.vendor_id = id
binding.pry
u.save
redirect_to admin_vendor_path(resource)
end
end


and this is the routes:



 resources :vendors, only: [:show, :update] do
resources :users, controller: 'vendors/vendor_users' do
member do
post :update_add_staff


I hope someone can help me I don't really know what to do







ruby-on-rails ruby activeadmin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 2:58







Ejaye

















asked Nov 23 '18 at 10:05









EjayeEjaye

162




162













  • If u.staff_user != false, your action will not perform redirect

    – Pavel Oganesyan
    Nov 23 '18 at 10:44



















  • If u.staff_user != false, your action will not perform redirect

    – Pavel Oganesyan
    Nov 23 '18 at 10:44

















If u.staff_user != false, your action will not perform redirect

– Pavel Oganesyan
Nov 23 '18 at 10:44





If u.staff_user != false, your action will not perform redirect

– Pavel Oganesyan
Nov 23 '18 at 10:44












1 Answer
1






active

oldest

votes


















0














@Pavel is right. Your member_action has an if statement. If u.staff_user == false, then it will redirect_to admin_vendor_path(resource), which I assume is working. Otherwise, no render or redirect has happened, so rails will default to attempting to render, and it will try to render the action update_add_staff.



To resolve this, you could add an else section to your if statement, or move the redirect_to outside of the if block.



# This should resolve the issue
member_action :update_add_staff, method: :put do
u = User.find(params[:vendor][:staff_user])
if u.staff_user == false
u.staff_user = true
u.vendor_id = id
binding.pry
u.save
else
flash[:error] = "Access denied"
end

redirect_to admin_vendor_path(resource)
end





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444544%2ftemplate-is-missing-in-ruby-on-rails-using-active-admin%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    @Pavel is right. Your member_action has an if statement. If u.staff_user == false, then it will redirect_to admin_vendor_path(resource), which I assume is working. Otherwise, no render or redirect has happened, so rails will default to attempting to render, and it will try to render the action update_add_staff.



    To resolve this, you could add an else section to your if statement, or move the redirect_to outside of the if block.



    # This should resolve the issue
    member_action :update_add_staff, method: :put do
    u = User.find(params[:vendor][:staff_user])
    if u.staff_user == false
    u.staff_user = true
    u.vendor_id = id
    binding.pry
    u.save
    else
    flash[:error] = "Access denied"
    end

    redirect_to admin_vendor_path(resource)
    end





    share|improve this answer




























      0














      @Pavel is right. Your member_action has an if statement. If u.staff_user == false, then it will redirect_to admin_vendor_path(resource), which I assume is working. Otherwise, no render or redirect has happened, so rails will default to attempting to render, and it will try to render the action update_add_staff.



      To resolve this, you could add an else section to your if statement, or move the redirect_to outside of the if block.



      # This should resolve the issue
      member_action :update_add_staff, method: :put do
      u = User.find(params[:vendor][:staff_user])
      if u.staff_user == false
      u.staff_user = true
      u.vendor_id = id
      binding.pry
      u.save
      else
      flash[:error] = "Access denied"
      end

      redirect_to admin_vendor_path(resource)
      end





      share|improve this answer


























        0












        0








        0







        @Pavel is right. Your member_action has an if statement. If u.staff_user == false, then it will redirect_to admin_vendor_path(resource), which I assume is working. Otherwise, no render or redirect has happened, so rails will default to attempting to render, and it will try to render the action update_add_staff.



        To resolve this, you could add an else section to your if statement, or move the redirect_to outside of the if block.



        # This should resolve the issue
        member_action :update_add_staff, method: :put do
        u = User.find(params[:vendor][:staff_user])
        if u.staff_user == false
        u.staff_user = true
        u.vendor_id = id
        binding.pry
        u.save
        else
        flash[:error] = "Access denied"
        end

        redirect_to admin_vendor_path(resource)
        end





        share|improve this answer













        @Pavel is right. Your member_action has an if statement. If u.staff_user == false, then it will redirect_to admin_vendor_path(resource), which I assume is working. Otherwise, no render or redirect has happened, so rails will default to attempting to render, and it will try to render the action update_add_staff.



        To resolve this, you could add an else section to your if statement, or move the redirect_to outside of the if block.



        # This should resolve the issue
        member_action :update_add_staff, method: :put do
        u = User.find(params[:vendor][:staff_user])
        if u.staff_user == false
        u.staff_user = true
        u.vendor_id = id
        binding.pry
        u.save
        else
        flash[:error] = "Access denied"
        end

        redirect_to admin_vendor_path(resource)
        end






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 13 '18 at 22:41









        Amiel MartinAmiel Martin

        3,75712427




        3,75712427
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444544%2ftemplate-is-missing-in-ruby-on-rails-using-active-admin%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen