zoukankan      html  css  js  c++  java
  • 使用一个知名rails模版创建rails app(5月14日)出现的问题及解决办法

    一直用这个模版来创建rails app,运行的都还挺好,但前一段事件有些小状况,当时记了下来,但一直没空整理成BLOG

    rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-devise-rspec-cucumber-template.rb -T

    状况1:

    当选择安装rolify和cancan的时候,会报一个奇怪的错误,当前的程序也暂时用不到,因此简单规避即可-不选择它

     

    状况2:

    接着运行rake spec时,出现了一个错误:

     rake spec cucumber出错,报告:
    Failure/Error: Unable to find matching line from backtrace
    ActiveRecord::ConnectionNotEstablished:
     
    ActiveRecord::ConnectionNotEstablished

    这肯定是没有告诉SPEC使用Mongodb的缘故,幸好以前有成功的应用,对比了一下,发现少了一个文件:database_cleaner.rb

    解决办法:
    在spec/support目录下,增加一个文件:database_cleaner.rb
    RSpec.configure do |config|
      config.before(:suite) do
        DatabaseCleaner[:mongoid].strategy = :truncation
      end
    end
     

    状况3:

    当运行rails s,打开网页,点击signup时,出现了一个错误如下:
     ActionView::Template::Error (Missing partial shared/links with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
      * "/home/caiqingfeng/workspace/myapp/app/views"
      * "/usr/share/ruby-rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.0/app/views"
    ):
        1: <% ActiveSupport::Deprecation.warn "Rendering partials devise/_links.erb is deprecated" \
        2:   "please use devise/shared/_links.erb instead."%>
        3: <%= render "shared/links" %>
      app/views/devise/registrations/new.html.haml:22:in `_app_views_devise_registrations_new_html_haml__909858688_82016300'

    云云,
    奇怪的是应该执行haml,但还是erb没有的错误,用了一个简单的办法搞定它:在Gem文件夹里拷贝这个_links.erb到app/views/devise目录下。
     
    总结:
    这个模版如此之强大,组合太多,有版本更新的时候,难免有些状况没有考虑到,幸运的是,都还有比较简单的办法搞定本文碰到的问题,希望对一些朋友有所帮助。
  • 相关阅读:
    MySQL主从复制原理
    MySQL调优
    apache禁止php解析--安全
    apache禁止指定的user_agent访问
    python---日常练习
    字符、字节的概念和区别;编码概念
    Django模型初识
    git安装
    Django--Hello
    fillder---断言/打断点,更改提交数据
  • 原文地址:https://www.cnblogs.com/mobileinternet/p/2543600.html
Copyright © 2011-2022 走看看