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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:07:22+00:00 2026-05-11T11:07:22+00:00

newbie here, first post. I just spent like 4 hours trying to assign one

  • 0

newbie here, first post.

I just spent like 4 hours trying to assign one category to a post (trying out a regular blog thing) via radio buttons, to no avail. The association is working fine, and ultimately I managed to get it working with a select menu, but for some reason it seems radio buttons are simply not meant for that.

I really don’t like using a select menu for that because I only have 4 categories and having to click twice to select a single one is 1 click too many. So I would really like to use radio buttons instead.

I checked out the other question on the subject and searched the web senseless but it only helped me get a more diverse array of errors: Undefined methods, AssociationTypeMismatch, category_ids of 0, you name it. So I gave up for today and decided to create a account and see if anyone can crack this one. Any help will be appreciated.

Thanks.

  • 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. 2026-05-11T11:07:23+00:00Added an answer on May 11, 2026 at 11:07 am

    Here we go. In RailsCasts Episode 17 Ryan uses habtm and checkboxes to do this kind of thing. I modified it to use belongs_to and radio buttons. Thanks for the exercise.

    > script/generate scaffold category category_name:string > script/generate scaffold post post_name:string, post_content:text, category_id:integer 

    Post Model

    Class Post < ActiveRecord::Base    belongs_to :category End 

    Post Create View (removed the default textbox for category_id)

    ... <p>  <% for category in Categories.find(:all) %>    <div>        <%= radio_button_tag 'post[category_id]', category.id, @post.category_id == category.id %><%= category.name %>    </div>  <% end %> </p> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In my opinion, you should ALWAYS use a BLL (Business… May 11, 2026 at 4:34 pm
  • Editorial Team
    Editorial Team added an answer Gah! EBCAK! Turns out when I copied the jquery javascript… May 11, 2026 at 4:34 pm
  • Editorial Team
    Editorial Team added an answer I am not aware of any standard, but the way… May 11, 2026 at 4:34 pm

Related Questions

I'm struggling with a T-SQL procedure and I am hoping you can help. I
I'm a C newbie and I was just trying to write a console application
Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
I am a newbie to Database programming. After inserting a couple of rows into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.