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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:36:13+00:00 2026-06-13T18:36:13+00:00

I have a radio button within my form as follows <div class=btn-group data-toggle=buttons-radio> <%=

  • 0

I have a radio button within my form as follows

    <div class="btn-group" data-toggle="buttons-radio">
      <%= f.radio_button :start_year, :class=> "btn", :value=> '2007' %> 2007
      <%= f.radio_button :start_year, :class=> "btn", :value=> '2008' %> 2008
      <%= f.radio_button :start_year, :class=> "btn", :value=> '2009' %> 2009
    </div>

I am using twitter bootstrap

I want to do something like the following:

    <div class="btn-group" data-toggle="buttons-radio">
      <%= f.radio_button :start_year, :class=> "btn", :value=> '2007', if @dates.start_year == 2007 :checked => true end %> 2007
      <%= f.radio_button :start_year, :class=> "btn", :value=> '2008', if @dates.start_year == 2008 :checked => true end %> 2008
      <%= f.radio_button :start_year, :class=> "btn", :value=> '2009', if @dates.start_year == 2009 :checked => true end %> 2009
    </div>

But I get the following error:

syntax error, unexpected keyword_ensure, expecting ')'
syntax error, unexpected keyword_end, expecting ')'

I must be making a mistake in the if statement within the radio button, but I’m not sure how exactly to correct this

  • 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-13T18:36:14+00:00Added an answer on June 13, 2026 at 6:36 pm

    Try

    <%= f.radio_button :start_year, :class=> "btn", :value=> '2007', :checked => Proc.new { @dates.start_year == 2007 ? true : false } %> 2007
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this group of radio buttons in which each of individual button has
I have a form which consists of six radio buttons within a frame which
I have 2 radio button with 2 group. The structure is like this Main
I have a form with n multiple choice questions implemented as radio buttons (using
I have a page with radio buttons and a textarea that populates data dynamically
I have a group of radio buttons, and have styled them so that they
I have radiobutton in Silverlight 3 with FontSize=20. Within the control the radio dialog
I have a radio button list and some of the labels are quite long
I have 2 radio button with values New & Existing. If user chooses New,
I have a radio button control adaptor that attempts to render the radio button

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.