how to use a separate erb file for a controller free of application.erb rails
I am trying to use a different .erb
file instead of default application.erb
, I followed as its stated in https://guides.rubyonrails.org/layouts_and_rendering.html#finding-layouts
I have created a route in routes.rb as
get "/vue/v1/" => "vue#vue"
a controller as vue_controller.rb
and its content is
class VueController < ApplicationController
layout "vue"
def vue
end
end
and in my view/layouts/
, I also have created a file as vue.html.erb
so that the controller can use it. The content of vue.html.erb
is as simple as <%= javascript_pack_tag 'application' %>
but whenever I go to "/vue/v1/"
, It only gave me error as
VueController#vue is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
ruby-on-rails
add a comment |
I am trying to use a different .erb
file instead of default application.erb
, I followed as its stated in https://guides.rubyonrails.org/layouts_and_rendering.html#finding-layouts
I have created a route in routes.rb as
get "/vue/v1/" => "vue#vue"
a controller as vue_controller.rb
and its content is
class VueController < ApplicationController
layout "vue"
def vue
end
end
and in my view/layouts/
, I also have created a file as vue.html.erb
so that the controller can use it. The content of vue.html.erb
is as simple as <%= javascript_pack_tag 'application' %>
but whenever I go to "/vue/v1/"
, It only gave me error as
VueController#vue is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
ruby-on-rails
add a comment |
I am trying to use a different .erb
file instead of default application.erb
, I followed as its stated in https://guides.rubyonrails.org/layouts_and_rendering.html#finding-layouts
I have created a route in routes.rb as
get "/vue/v1/" => "vue#vue"
a controller as vue_controller.rb
and its content is
class VueController < ApplicationController
layout "vue"
def vue
end
end
and in my view/layouts/
, I also have created a file as vue.html.erb
so that the controller can use it. The content of vue.html.erb
is as simple as <%= javascript_pack_tag 'application' %>
but whenever I go to "/vue/v1/"
, It only gave me error as
VueController#vue is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
ruby-on-rails
I am trying to use a different .erb
file instead of default application.erb
, I followed as its stated in https://guides.rubyonrails.org/layouts_and_rendering.html#finding-layouts
I have created a route in routes.rb as
get "/vue/v1/" => "vue#vue"
a controller as vue_controller.rb
and its content is
class VueController < ApplicationController
layout "vue"
def vue
end
end
and in my view/layouts/
, I also have created a file as vue.html.erb
so that the controller can use it. The content of vue.html.erb
is as simple as <%= javascript_pack_tag 'application' %>
but whenever I go to "/vue/v1/"
, It only gave me error as
VueController#vue is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
ruby-on-rails
ruby-on-rails
asked Dec 31 '18 at 7:16
Junaid FarooqJunaid Farooq
6411723
6411723
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
what you are doing wrong is in your controller, you don't have a view for your vue
action. Try adding a erb file in your views/vue
Okay then what is the use oflayout
in the controller? it's useless?
– Junaid Farooq
Dec 31 '18 at 7:58
1
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984677%2fhow-to-use-a-separate-erb-file-for-a-controller-free-of-application-erb-rails%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
what you are doing wrong is in your controller, you don't have a view for your vue
action. Try adding a erb file in your views/vue
Okay then what is the use oflayout
in the controller? it's useless?
– Junaid Farooq
Dec 31 '18 at 7:58
1
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
add a comment |
what you are doing wrong is in your controller, you don't have a view for your vue
action. Try adding a erb file in your views/vue
Okay then what is the use oflayout
in the controller? it's useless?
– Junaid Farooq
Dec 31 '18 at 7:58
1
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
add a comment |
what you are doing wrong is in your controller, you don't have a view for your vue
action. Try adding a erb file in your views/vue
what you are doing wrong is in your controller, you don't have a view for your vue
action. Try adding a erb file in your views/vue
answered Dec 31 '18 at 7:42
G.BG.B
2,89321539
2,89321539
Okay then what is the use oflayout
in the controller? it's useless?
– Junaid Farooq
Dec 31 '18 at 7:58
1
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
add a comment |
Okay then what is the use oflayout
in the controller? it's useless?
– Junaid Farooq
Dec 31 '18 at 7:58
1
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
Okay then what is the use of
layout
in the controller? it's useless?– Junaid Farooq
Dec 31 '18 at 7:58
Okay then what is the use of
layout
in the controller? it's useless?– Junaid Farooq
Dec 31 '18 at 7:58
1
1
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
Layouts are not your HTML views. Its basically a container in which view is rendered. Give it a try guides.rubyonrails.org/layouts_and_rendering.html This will help you understand the concept. Plus you also need a Vue layout in which the actual view will be rendered
– G.B
Dec 31 '18 at 8:05
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984677%2fhow-to-use-a-separate-erb-file-for-a-controller-free-of-application-erb-rails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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