jenkins Email-EXT plugins
2016-01-12 19:25
399 查看
Let's say you provide a select menu for setting which category a given product belongs to, but you also want the option of creating a new category by typing the name in a text field. See a great way to do that in this episode.
<!-- views/products/_form.rhtml --> <p> <label for="product_category_id">Category:</label><br /> <%= f.collection_select :category_id, Category.find(:all), :id, :name, :prompt => "Select a Category" %> or create one: <%= f.text_field :new_category_name %> </p> # models/product.rb belongs_to :category attr_accessor :new_category_name before_save :create_category_from_name def create_category_from_name create_category(:name => new_category_name) unless new_category_name.blank? end
相关文章推荐
- 解决错误error: RPC failed; result=56, HTTP code = 200
- Xcode6中去掉默认的Main.storyboard
- 解决RHadoop错误:PipeMapRed.waitOutputThreads(): subprocess failed with code 1
- FIN_WAIT1 能持续多久?你知道吗
- NSSearchPathForDirectoriesInDomains和NSHomeDirectory
- 人工智能之优化算法1-蚁群优化算法
- raiserror的用法
- Daily Scrum – 1/12
- STM32学习【1】ERROR:RAM check failed @ADDRESS 0x20000000
- log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFil
- Storm ack和fail机制再论
- windows server 2008服务器 做raid0
- 使用Genymotion安装APK出现错误INSTALL_FAILED_CPU_ABI_INCOMPATIBLE的解决办法
- 什么是混合RAID编辑
- Git查看并修改name和email
- 火狐打开百度首页自动跳转到如下网页:http://www.baidu.com/baidu.html?from=noscript
- Ubuntu下wpa_supplicant命令导致WPA: 4-Way Handshake failed
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile)
- LeetCode 217 Contains Duplicate(包含重复数字)(Vector、hash)
- rails导出CSV XLS 中文乱码解决办法