rails开发随手记-0
生活随笔
收集整理的這篇文章主要介紹了
rails开发随手记-0
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
helper默認是只在view中可用的,如果在controller中也要使用,要在ApplicationController中 include
如果model中如果有叫做type的列的話,會觸發rails的Single Table Inheritance ,放棄它吧,不好用,還是安心使用外鍵約束吧。給model加上self.inheritance_column = nil disable它
controller中的參數變量會傳到對應的view中比如:
def new@user = User.new end---------------------------------new.html.erb---------------------- <%= form_for(@user) do |f| %><%=f.label :name %><%=f.text_field :name %><%=f.label :email %><%=f.text_field :email %><%=f.label :type %><%= f.select(:type, options_for_select([['admin', 'admin'], ['teacher', 'teacher'], ['student', 'student']])) %><%=f.label :password %><%=f.password_field :password %><%=f.label :password_confirmation %><%=f.password_field :password_confirmation %><%= f.submit "Create my account"%> <% end %>?
轉載于:https://www.cnblogs.com/jzlikewei/archive/2013/03/31/2992446.html
總結
以上是生活随笔為你收集整理的rails开发随手记-0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Session 丢失问题
- 下一篇: java项目打jar包