12月7日,几个错误,拼写错误,遗漏符号:,记忆有误,max-width的作用。gem mini_magick, simple_form

❌:

1. /Users/chentianwei/jdstore3/jdstore/config/routes.rb:6:in `block in <top (required)>': undefined local variable or method `admin' for #<ActionDispatch::Routing::Mapper:0x007fd2b043d6b0> (NameError)

解释:在路径文件出错,查找

  namespace admin do
    resources :products
  end

 发现admin前面没有加 

2.在索引界面:index.html.erb,删除按钮的代码,路径是product_path(@product) ,和show.html.erb的路径一样,否则会报告错误。 

3. data:{ confrim:"Are you sure?"} 这是❌的, 单词拼写错误,confirm.

4.增加is_admin列的时候,语法不能忽略default: false/true 

完整写法:add_column :users, :is_admin, :boolean, default: false 

5. max-width:让block元素在浏览器窗口小于自身的时候不至于伸出窗口边界。 


 carrierwave 用于上传并储存文件。如果要上传图片,需要mini_magick等gem配合使用。


simple_form 可以客制化属性的类型:also lets you overwrite the default input type it creates:

用到 as: :  

 https://github.com/plataformatec/simple_form

 pasting

<%= simple_form_for @user do |f| %>
  <%= f.input :username %>
  <%= f.input :password %>
  <%= f.input :description, as: :text %>
  <%= f.input :accepts,     as: :radio_buttons %>
  <%= f.button :submit %>
<% end %>
原文地址:https://www.cnblogs.com/chentianwei/p/7997525.html