Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3801192
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:00:40+00:00 2026-05-19T14:00:40+00:00

I suppose it should do justice to state what I think I know so

  • 0

I suppose it should do justice to state what I think I know so far as well as what I’ve done:

1) I created the app and did my first db migration; I now have my dev, test and production databases. The dev db has a table called ‘wines’.

2) I made a scaffold which created the necessary files.

3) The basic index/update/destroy methods are set up and I can browse the pages.

4) From what I gather, the ActiveRecord class “Wine” automatically inherits properties from the database? Each column is a property and each row in the table ‘wines’ is a potentially instantiated object which is called from the wine_controller script.

The problem I’m having now is that I want to create a common layout that all controllers use. The only things that will change will be the page title, potentially some <link> tags in the header, the <body> attributes (javascript onload events most likely) and whatever lies inside the <body> tag.

I find myself looking up functions that will do what I want (like “favicon_link_tag”, “stylesheet_link_tag” and “auto_discovery_link_tag”…) but I can’t find the right place to PUT them! I know this has something to do with my lack of understanding of how things are executed/inherited. For example if I were to declare @pageTitle in application_controller.rb and use @pageTitle in ApplicationHelper it won’t work. Or even using “stylesheet_link_tag” in application_controller.rb throws an error. I’m just not getting something.

How does each thing relate to another in terms of chronological execution, scope, etc.?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:00:41+00:00Added an answer on May 19, 2026 at 2:00 pm

    In your “app/views” directory there is a folder called “layouts.” By default there should be an “application.html.erb” file in there, but if there isn’t you can create it.

    Your “application” layout file is the default layout file used by any view. However, if you want a particular controller to use a different view, you can override this. See this railscast, and this one is helpful too.

    The main thing to understand is the content from any particular view will show up wherever the yield method appears in your application layout. The main ‘yield’ block gets the view file specified by your controller action, but you can mark anything inside any view to be passed to another yield block instead. For instance, the “title” example you gave could be passed to the head of your application layout. See this railscast for a detailed example of that.

    For more, you should read the Rails Guide, and you might want to consider picking up a Rails starter book.

    I got my feet wet with “Beginning Rails 3,” which was a phenomenal introduction to the framework. A couple days with that book and it was all making sense to me, and I was developing faster than I ever had before. Rails rocks once you get to know it, but it’s definitely worth going through a book.

    Please continue to ask questions, I’ll help if I can 🙂

    -EDIT- To answer your question about control flow, it basically works like this:

    1. Your browser sends a GET request for a particular URL.

    2. The router takes that request, matches it to a controller action, triggers that controller action, and provides the controller any parameters associated with the request. For instance: if you requested example.com/posts/123?color=red this would trigger the SHOW action of your posts_controller, and would pass {:color => ‘red’} to the params hash. You would access that using params[:color]

    3. The controller action does its thing, and when it’s done it renders output. By default it renders whatever view is located in app/<controller_name>/<action_name>, and will whichever file matches the extension appropriate to the request (ie an AJAX request would trigger <action_name>.js.erb and a GET request would trigger <action_name>.html.erb.

      • You can override this using the render method, for example by passing render 'foo/bar' to render using the view for FooController, Bar action instead of your current action.

      • Note that no matter what you render, the data available to the view is whatever is in the specific controller action the router triggered, not the controller action that would ‘normally’ render that view.

    4. The view file is parsed using the data from the controller that called it. If you have any content_for methods then the view code that is inside the content_for block will go where you tell it, otherwise everything else will go to the main YIELD block in your application layout (or whatever layout your controller specified instead).

    5. The application layout is parsed, and the content from the view is inserted into the appropriate areas.

    6. The page is served to the user.

    That’s a simplification in some ways, but I think it answers your question. Again, feel free to keep asking 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I suppose it should be done with IMediaSeeking SetPositions , but I don't know
I'm testing my app on HTC Wildfire running Android 2.2.1. I suppose it should
I suppose there should be a way to set a cookie to be accessible
I suppose button should has Close title in the code below, but it has
How should I use callback functions in parsekit? suppose I have the following rule:
Suppose I have a class with a string instance attribute. Should I initialize this
Suppose, I write class A { }; The compiler should provide (as and when
Suppose I want to reflect exception in the log. Should I pass stack trace
This seems like it should be obvious but I can't figure it out. Suppose
Suppose I have a function: function test(){ //should I define global variable here //like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.