In the last post concerning public fixed web pages, we have actually seen the strength method of producing extremely fixed public web pages in Bed rails: Simply place them right into the app/assets/public
folder, along with your mistake web pages, as well as web link to them from the courses.
However suppose you intend to include a little small piece of dynamicity to your web page, as well as as an example program
off a little example of sources to customers that have not registered to your web page yet? Or you simply desire all the great Bed rails assistants to be offered on your “fixed” web page.
Likewise, most likely you aren’t a developer or you simply do not have much time for producing a fresh brand-new layout for your fixed web page. You simply intend to recycle your application’s design.
The difficulty with public web pages is that they are a type of organization as well as domain name reasoning. As well as if you have actually collaborated with Bed rails in the past simply a little, you’ll understand that Bed rails does not appreciate your sensations as well as organization reasoning. It’s for you to determine just how to design as well as where to place it.
So normally, there are lots of methods as well as various areas just how to structure your organization reasoning.
There are 2 significant methods:
- Produce a public/static web pages controller
- Make your public web page a source
In this post, we’ll check out one of the most typical one: Developing a public web page controller.
Allow’s presume you have actually produced an application that permits customers to find out memory strategies. In this circumstance, you may gain from having a controller like that:
# public_pages_controller. rb.
course PublicPagesController.
def residence.
# Your expensive/ web page may not be doing anything, or it may really.
# allow customers subscribe for an e-newsletter or updates concerning your upcoming.
# item:.
end.
def around.
# Your/ concerning web page may be extremely boring as well as fixed defining you as well as.
# your group ...
end.
def memory_palace_technique.
# Right here you describe to your customers what a memory royal residence is as well as just how they can.
# develop some in your application with an instance:.
MemoryPalace.sample.
end.
def memory_major_system_technique.
# An additional attribute of your application may be to detail a various memory strategy.
# In this situation you display an example of a various source:.
Peg.where( kind: "initial", language: params["language"]). initially.
end.
end.
Keeping that you can simply connect to your web pages from the courses such as this:
# routes.rb.
Rails.application.routes.draw do.
# Admin courses.
#.
# ...
#.
# Visited individual courses.
#.
# ...
#.
# Public courses.
origin 'web pages #home'.
obtain '/ concerning', to: 'public_pages #about'.
obtain '/ get in touch with', to: 'public_pages #memory _ palace_technique'.
obtain '/ aid', to: 'public_pages #memory _ major_system_technique'.
# ... Even more fixed web pages like ToC as well as personal privacy web pages ...
end.
That’s it. Simply include your html.erb
sights in the particular folder with the appropriate name as well as you are done.
This appears like having all the fixed web pages in one location, yet it can develop a little a layout difficulty when you begin doing these vibrant points as well as begin presenting examples based upon some individual input (which is not extremely fixed any longer, yet it’s public, as well as your “fixed” web pages may advance right into something extra to life as well as interactive).
In this situation, attempting to think about your public fixed web pages as sources can enhance your total layout as well as bring about far better remedies. You will certainly see this at work in the following post, where I will certainly reveal you which layout obstacles I faced as well as the guidance I took that made the entire configuration much better.