css - 将 CSS 类添加到 date_select

标签 css ruby-on-rails

我有以下 date_select 助手。我想添加一个类,但它不生成 HTML。

<%= date_select :recipient, :birthday, :order => [:day, :month, :year], :start_year => 1920, :end_year => 2013, :class => "input-mini" %>

我也按照一些解决方案的建议使用哈希进行了尝试,但出现语法错误:

<%= date_select :recipient, :birthday, :order => [:day, :month, :year], :start_year => 1920, :end_year => 2013, {:class => "input-mini"} %>

不确定我是否真的了解何时以及如何使用散列对其进行格式化。

最佳答案

经过验证的答案对我不起作用,有用的是:

<%= date_select
    :recipient,
    :birthday,
    {:order => [:day, :month, :year], :start_year => 1920, :end_year => 2013},
    {:class => "input-mini"}
%>

根据 docs 这更有意义:

date_select(object_name, method, options = {}, html_options = {})

关于css - 将 CSS 类添加到 date_select,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12714548/

相关文章:

ruby-on-rails - rails 上的 ruby : Image downloads with Authentication/Authorization/Time outs

ruby-on-rails - Rails 消费外部 API 需要错开消费

ruby-on-rails - Rails 以一长串关于已初始化常量的警告开始

css - 当我悬停时链接正在移动

javascript - 单击按钮时防止 Bootstrap 模式打开

javascript - 隐藏初始 3d 变换动画

ruby-on-rails - 检测应用程序是否作为 HTTP 服务器启动(rake 任务、rconsole 等)

html - 为 div 中的各个元素着色

javascript - 如何将正方形 div 对 Angular 分成 4 个可点击的部分?

mysql - Active Record 模型与同一类的 2 个实例有关系