-
新mac 系统,安装rmagick gem包缺少头文件错误,bundle失败。
解决方案:使用macport重新安装imagemagick,安装xcode命令行工具,并在偏好工具中设置。 -
rails中dropzone代码
<link href="//cdn.bootcss.com/dropzone/4.3.0/min/dropzone.min.css" rel="stylesheet">
<div class="row">
<div class="col-xs-8 col-xs-offset-2">
<h2>上传图片:</h2>
</div>
<div class="col-xs-8 col-xs-offset-2">
<%= form_tag({action: :save_pic}, multipart: true ,class: "dropzone",id: "dz_save_pic") do %>
<div class="fallback">
<%= file_field_tag 'picture' ,accept:'image/*'%>
</div>
<% end %>
</div>
<div class="col-xs-8 col-xs-offset-2">
<h1></h1>
</div>
<div class="col-xs-6 col-xs-offset-2">
<%= link_to '完成' ,fixed_asset_path ,class: "btn btn-primary" %>
<!-- <%= link_to '完成' ,{action: "show"} ,class: "btn"%> -->
</div>
</div>
<% content_for :script do %>
<script src="//cdn.bootcss.com/dropzone/4.3.0/min/dropzone.min.js"></script>
<%= javascript_include_tag "fixed_assets.js" %>
<script type="text/javascript">
Dropzone.prototype.defaultOptions.dictDefaultMessage = "点击此处上传图片,或将需要上传的图片拖拽到此处!";
Dropzone.prototype.defaultOptions.acceptedFiles = "image/*";
</script>
<% end %>
- link_to 方法的第二个参数为一个hash,一般用 XXXX_path ,如果用 action 形式需要用{} 花括号包起来。花括号中还可以写链接的参数例如:
link_to "WRONG!", controller: "articles", id: "news", class: "article"
# => <a href="/articles/index/news?class=article">WRONG!</a>
正确的写法:
link_to "Articles", articles_path, id: "news", class: "article"
# => <a href="/articles" class="article" id="news">Articles</a>
网友评论