Reputation: 6476
I want to have pages that are not rendered through rails so that they don't have the default header and footer to every page that I made.
So I have a website where you can post things, but when you go to the root (www.localhost:3000/) I want you to have to either sign in with an account or create an account. These pages have a entirely separate header and footer, they should almost be a different website in the sense that they really have no connection with the real site other than getting past them before you have access to it.
I'm thinking that these pages need to be in the public folder but I'm not really sure.
Upvotes: 2
Views: 134
Reputation: 25377
You can either put static html files in public/
as you suggested, but a far better approach would be to use Rails after all, just with a different layout.
With Rails, you would have created a file such as app/views/layouts/application.html.erb
, which uses the header and footer of your app. However, Rails does not force you to use this layout all the time, unless you want to.
For example, consider creating another layout like app/views/layouts/not_logged_in.html.erb
. Now, you can use this new layout in the controllers which handle logins and sign ups:
class LoginController < ApplicationController
layout 'not_logged_in'
# def create, show, etc.
end
class SignUpController < ApplicationController
layout 'not_logged_in'
# def create, show, etc.
end
These two controllers will now use the not_logged_in.html.erb
layout, while all other controllers will use application.html.erb
.
It's also possible to not use a layout at all for your controller:
class LayoutLessController < ApplicationController
layout nil
end
Upvotes: 2
Reputation: 23662
You can't program pages in the public directory (i.e. you serve .html files, no ruby). From what I understand of your request, it can definitely be done through views. All you need to do is set up a different layout file in the views/layouts directory and point to that file in your controller like so:
class MyController < ApplicationController
layout "differentLayout"
...
end
Inside differentLayout.html.erb you require different header and footer partials.
Upvotes: 0