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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:53:24+00:00 2026-05-31T00:53:24+00:00

I am working on a simple intranet application made with Rails 3.1. I have

  • 0

I am working on a simple intranet application made with Rails 3.1.

I have a model for links which has the following fields:

name:string
url:string
colour:string

I have put the colour attribute into a class in the view, like so:

<a href="linkaddress" class="<%= link.colour %>">Link Name</a>

At the moment in the new link form I just have a simple form input in which the user can type anything and it will become the href class as expected.

What I would like to do is create a dropdown list of preset options, these options are simply red, green and blue (as an example). As this seems fairly simple, I don’t think there is any need for a helper.

I have read a few other questions and answers on SO and they seem to show examples where you have the name followed by an ID number. I just want to have the code below:

<select name="colour">
 <option value="red">Red</option>
 <option value="green">Green</option>
 <option value="blue">Blue</option>
</select>

I’m sure this is simple but I can’t get my head around it. I’ve read the Rails API info and the select_for_tag has confused me!

  • 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-31T00:53:26+00:00Added an answer on May 31, 2026 at 12:53 am

    Just use a standard select element in your form to set the colour variable:

    <%= f.select :colour, options_for_select([["Red", "red"], ["Green", "green"]], @link.colour) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in simple application in which I need to post data to
I am working on simple application which creates google calendar (under it's own account).
I have a relatively simple site that I'm working up for an intranet environment.
I am Working on simple login application in which user is first shown login
hi iam currently working in simple amimation app in which i implement following code
I have paperclip in Rails (3) working with simple cropping, for example the blow
Working a simple custom authentication portion for my Ruby on Rails application. I'm trying
I'm working with my simple PHP captcha algorithm ( http://www.source.ofitall.com/devel/captcha.php ) and I have
I have a simple working PHP script to write an HTML table from a
I am working on simple form to validate fields like this one. public class

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.