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 8941629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:21:03+00:00 2026-06-15T11:21:03+00:00

I made a blogpost with two entries ( title , content ) like this

  • 0

I made a blogpost with two entries (title, content) like this

rails generate scaffold Post title:string content:text

This works, but

  1. What if I want to add a new input area later? Ex. author field or something. Where do I add more fields to my Post scaffold?

  2. I made a stylesheet style.css inside my public directory. Its just sitting there. How do I link it to my file in app/views/post/new.html.erb for example?

  3. Where can I learn all the tweaks for scaffolding a specific field? Ex. I want the title input field to not contain special characters (ex. @#$%) or not be more than certain length.

I am using windows and rails 3.2.8.

  • 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-06-15T11:21:04+00:00Added an answer on June 15, 2026 at 11:21 am

    A 3 in 1 question 🙂

    1st answer

    As others said you need to modify your table to have the new fields, and this can be easily done with a migration:

    rails generate migration AddAuthorToPost author:string
    

    But you also need to modify your views, because it won’t contain the new field. The corresponding views are in app/views/posts (look for edit.html.erb and new.html.erb).

    Of course you’ll need to run your migration on your database:

    rake db:migrate
    

    2nd answer

    You can add your stylesheets to your views in app/views/posts but I recommend you to use layouts for your application, The layouts sit in the app/views/layouts. You can simply create an application.html.erb in your layouts directory and put your CSS includes there.

    <html>
      <head>
        <%= stylesheet_link_tag "custom" %>
      </head>
      <body>
        <%= yield %>
      </body>
    </html>
    

    The yield block will contain the actual output of your views, so you should remove these parts from the existing views.

    3rd answer

    If you want to control the accepted characters for a certain field, you could do it in a validation in your model.

    validates :title,
      :format => { :with => /\A[a-zA-Z]+\z/, :message => "Only letters allowed" },
      :length => { :maximum => 20 }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Made this nice little loop for hiding and showing div's, works as a charm
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
I like the pattern I saw in this blog post ( http://marekblotny.blogspot.com/2009/04/conventions-after-rewrite.html ), where
I've read two articles about heap-spraying: Wikiepdia and this blog post . I understand
I was reading a blog-post of Ben Scheirman about some NHibernate tweaks he made
Made a custom obj called Item with some string fields and one float. .h
I made an application that passes trough an XML file and extracts the entries
I first learned about Data, context, and interaction (DCI) through this blog post .
I've made this Community Wiki because some may think it's open to debate and
I've followed this gist , this blog post and downloaded and deployed this example

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.