`
viva_yang
  • 浏览: 36188 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

rails select helper

 
阅读更多
<%=select_tag('site_id',options_for_select(@sites.collect{|s| [s.name,s.id]}.insert(0,["所有",0])) )%>

<%=select_tag('server_room_id',options_from_collection_for_select(ServerRoom.find_all_have_site_server_rooms,:id,:room))%>

<%=select('site','id',Site.find(:all).collect{|s| [s.name,s.id]}.insert(0,["所有",0]))%>这种在controller处理时格式params[:site][:id]

<%=select('site','isp_id',Isp.find(:all).collect{|i| [i.name,i.id]},{:selected=>@site.isp_id})%>选中某个值
分享到:
评论

相关推荐

    rails日期控件

    在Rails中,日期控件通常通过辅助方法(helper methods)实现,如`date_select`,`datetime_select`或`time_select`等。这些辅助方法能够自动生成HTML元素,与后台模型的日期字段对应,方便数据绑定和验证。 1. **...

    rails_com:Rails通用引擎

    IpHelper 支持通过ACME自动申请及更新SSL证书 当地人支持 &lt;&#37;= render 'shared/locales' %&gt; 支持枚举 # zh.yml activerecord : enum : notification : receiver_type : User : 全体用户 Member : 成员 t ...

    spree_variant_options_select

    bundle exec rails g spree_variant_options_select:install 测验 确保捆绑您的依赖项,然后为要运行的规范创建一个虚拟测试应用程序。 bundle bundle exec rake test_app bundle exec rspec spec 在测试与此扩展...

    NCKU-select-course-helper:成大选课小帮手

    NCKU选择课程助手一个开放源代码的网站,可从NCKU官方网站获取课程数据。 创建该网站的目的是为了帮助NCKU的学生轻松找到课程。 访问主要特点直观的用户界面更好的过滤功能以查找课程问题...版本Rails 4.2.0 Ruby 2.1.5

    InspiniaAdmin 2.7 Full Project

    Correct bg-colors in helper class Correct selected typo in css and css preprocessor Improve chat-avater styles Improve second level menu in Rails project Improve third level menu in md-skin Improve ...

    InspiniaAdmin 2.7 Seed Project

    Correct bg-colors in helper class Correct selected typo in css and css preprocessor Improve chat-avater styles Improve second level menu in Rails project Improve third level menu in md-skin Improve ...

    Ruby的25个编程细节(技巧、实用代码段)

    # Don't escape HTML entities in JSON, leave that for the #json_escape helper. # if you're ``` **解析:** 1. 如果定义了 `ActiveRecord`,则设置了两项配置: - `include_root_in_json` 为 `true`,表示在...

Global site tag (gtag.js) - Google Analytics