Ruby-on-Rails [SOLVED]: Style Rails Select Tag

Ruby-on-Rails [SOLVED]: Style Rails Select Tag

Home Forums Frameworks Ruby on Rails Tutorials Ruby-on-Rails [SOLVED]: Style Rails Select Tag

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #246745

    Cloudy Point
    Keymaster

    QuestionQuestion

    I have a form in rails with a select tag. I’m trying to style it like so:

    <%= f.select :role, collection: User.roles.keys.to_a, class:"form-control form-control-lg" %>
    

    I have tried the following:

    <%= f.select :role, collection: User.roles.keys.to_a, {}, class:"form-control form-control-lg" %>
    

    and

    <%= f.select (:role, collection: User.roles.keys.to_a, class:"form-control form-control-lg") %>
    

    But can’t get the style to apply to the drop down.

    #246746

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    Can you try the following

    <%= f.select :role, options_for_select(User.roles.keys.to_a, params[:role]), {}, class: 'form-control form-control-lg' %>
    

    I think will help

    Source: https://stackoverflow.com/questions/47959575/style-rails-select-tag
    Author: fool
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.