Questions about my Ruby on Rails Architecture
I am currently just beginning to work on a project. Here is my local server so that you can see what I am referring to:
128.48.204.195:3000
When you mouse over the top navigation for "Formats" I want开发者_运维技巧 to link to a page for formats.
The issue I am facing is whether to create a link by hand, or to use scaffolding, or other MVC architecture techniques to create what seems to be a whole infrastructure that gets made with controllers and models.
What are some elegant and good-practice ways to add new pages, which obviously come with models and controllers, in Ruby on Rails?
Generally you define the links in config/routes.rb
and make use of them in your views with the link_to
method, or in the controllers with redirect_to
.
The routing table helps define not only your link generator methods like format_path
, but the parser that takes the incoming request for /formats
and turns it into the parameters { :controller => 'formats', :action => 'index' }
for execution by that controller, if defined.
When you're talking about "pages" you may mean "actions I can execute in the context of my controllers" in which case you need to add routes and controllers in tandem. You may mean pages with more dynamic content, and that might mean a content management system, of which there are many available as plug-ins for Rails.
精彩评论