小编bru*_*077的帖子

SCSS和Sass有什么区别?

从我一直在阅读的内容来看,Sass是一种通过变量和数学支持使CSS更强大的语言.

与SCSS有什么区别?它应该是同一种语言吗?类似?不同?

css sass

1760
推荐指数
14
解决办法
74万
查看次数

如何重置Heroku应用程序并重新提交所有内容?

我正在构建一个我也在Heroku中测试的应用程序.我今天遇到了一些问题,不得不在我当地的git repo中回滚一个提交,但Heroku现在不会认识到我的更改说"一切都是最新的".

所以,跑步

git push heroku master
Run Code Online (Sandbox Code Playgroud)

heroku回应

Everything up-to-date
Run Code Online (Sandbox Code Playgroud)

这不是真的.

更新:我尝试过的事情

git push -f heroku master
git push --force heroku master
git push heroku +master
git push --force heroku +master
Run Code Online (Sandbox Code Playgroud)

然后在源代码中做了一些更改

git add.
git commit -a -m "Message" #(Then this commit shows in my git explorer)
git push heroku master #Everything up-to-date
Run Code Online (Sandbox Code Playgroud)

git heroku ruby-on-rails-3

50
推荐指数
4
解决办法
4万
查看次数

配置Active Admin has_many的标签

好吧,我有一个与on-to-many assoc相关的两个模型.

#models/outline.rb
    class Outline < ActiveRecord::Base
      has_many :documents
    end

#models/document.rb
    class Document < ActiveRecord::Base
      belongs_to :outline
    end

#admin/outlines.rb
    ActiveAdmin.register Outline do
      form do |f|
        f.inputs "Details" do
          f.input :name, :required => true
          f.input :pages, :required => true
          ...
          f.buttons
        end
        f.inputs "Document Versions" do 
          f.has_many :documents, :name => "Document Versions"  do |d|
            d.input :file, :as => :file
            d.buttons do
              d.commit_button :title => "Add new Document Version"
            end
          end
        end
      end
    end
Run Code Online (Sandbox Code Playgroud)

正如您在admin/outlines.rb中看到的那样,我已经尝试在has_many:documents中设置:name,在commit_button中设置:title,但这两个选项都不起作用,我也试过:legend,: title,和:label,而不是:.has_many中的名称.不工作.

这是该代码的结果: 截图

我要显示的是"文档版本"而不是"文档","添加新文档版本"而不是"添加新文档"

如果有人能有解决方案,那就太好了

ruby formbuilder formtastic ruby-on-rails-3 activeadmin

10
推荐指数
2
解决办法
8278
查看次数

在Rails 3.2 + SimpleForm中显示嵌套表单的错误字段

我有一个Flight嵌套在FlightLog模型中的模型.A FlightLog可能包含许多航班.

我正在使用SimpleForm和bootstrap安装,这使得在验证失败时可以包含错误类错误的表单元素.

问题是,即使为嵌套模型触发了验证,simple_fields_for中有错误的字段也没有被标记,因此无法确定哪个属性无效.

在调用create action时检查错误哈希后,我可以看到它正确填充了顶层的错误,以及每个资源中嵌套资源的错误.

如何修改simple_form的行为以将errors类添加到每个嵌套模型的控件组以匹配父行为?

提前致谢.

在此输入图像描述

ruby validation ruby-on-rails simple-form twitter-bootstrap

9
推荐指数
2
解决办法
7615
查看次数

Rails两个模型之间的多个关联

我在Rails 3应用程序中有Flight,Person和Glider模型.我已经定义了自定义关系,因为我需要多个外键引用来自flight表的Person.协会只能以单向工作.

class Flight < ActiveRecord::Base
  belongs_to :pilot, :class_name => "Person"
  belongs_to :instructor, :class_name => "Person"
  belongs_to :towplane_pilot, :class_name => "Person"
  belongs_to :airplane_instructor, :class_name => "Person"

  belongs_to :glider
  belongs_to :rep_glider, :class_name => "Glider"

  belongs_to :departure_airfield, :class_name => "Airfield"
  belongs_to :arrival_airfield, :class_name => "Airfield"

end

class Glider < Aircraft
  has_many :flights
  has_many :replaced_flights, :foreign_key => "rep_glider_id", :class_name => "Flight"
end

class Person < ActiveRecord::Base
  has_many :flights, :foreign_key => "pilot_id", :class_name => "Flight"
  has_many :instructed_flights, :foreign_key => "instructor_id", :class_name => "Flight"
  has_many …
Run Code Online (Sandbox Code Playgroud)

activerecord ruby-on-rails foreign-key-relationship ruby-on-rails-3

8
推荐指数
1
解决办法
4622
查看次数

在Mac OS X 10.5.8中安装Nokogiri gem的问题

我正在尝试在OS X Leopard(10.5.8)中的RVM托管Ruby 1.8.7安装下安装Nokogiri gem.

我收到以下错误:

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

        /Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no
-----
The function 'xmlHasFeature' is missing from …
Run Code Online (Sandbox Code Playgroud)

ruby rubygems osx-leopard nokogiri rvm

7
推荐指数
1
解决办法
5927
查看次数

我如何在FactoryGirl中为循环关联创建工厂?

我一直在努力为我在项目中定义的某些对象和关联创建工厂.我有一种循环的关联,其中一个对象与之后连接在一起的另外两个对象相关联.

+--------------+           +-------------+
|              |           |             |
| TestCase     +---------> | TestDataGrid|
|              |           |             |
+------+-------+           +------+------+
       |                          |
       |                          |
       |                          |
       v                          v
+--------------+           +--------------+
|              |           |              |
|              |           |              |
| TestVariable |           | TestDataSet  |
|              |           |              |
+------+-------+           +------+-------+
       |                          |
       |                          |
       |                          |
       |                          |
       |     +---------------+    |
       |     |               |    |
       |     |               |    |
       +---> | TestDataValue |<---+
             |               |
             +---------------+
Run Code Online (Sandbox Code Playgroud)
class TestCase < ActiveRecord::Base
  has_many :test_variables, …
Run Code Online (Sandbox Code Playgroud)

ruby unit-testing ruby-on-rails associations factory-bot

6
推荐指数
1
解决办法
499
查看次数

安装Apache Passenger,找不到Ruby开发标头

我有一个需要在Apache上托管的RoR应用程序,所以我一直在尝试安装Apache Passenger.当我运行以下命令时:

sudo passenger-install-apache2-module
Run Code Online (Sandbox Code Playgroud)

我明白了:

Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... not found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/local/bin/rake
 * rack... found
 * Apache 2... found at /usr/sbin/apache2
 * Apache 2 development headers... found at /usr/bin/apxs2
 * Apache Portable Runtime (APR) development headers... found at …
Run Code Online (Sandbox Code Playgroud)

apache ruby-on-rails apache2 passenger

5
推荐指数
2
解决办法
7223
查看次数

为什么使用itemController呈现空项的集合?

我正在学习Ember,同时遵循ember-cli的todomvc教程:http://thetechcofounder.com/getting-started-with-ember-js-using-ember-cli/

我在编辑待办事项的部分,需要添加editTodo动作TodoController.到目前为止一切都那么好,但它也说要itemControllereach把手助手上使用,告诉每个待办事项使用特定的控制器

在此输入图像描述.

问题是,当我添加itemControllereach模板(使用Emblem.js: each itemController='todo'),模板不再呈现在集合中的每个项目的标题,它只是使他们的空白:

在此输入图像描述

我不明白为什么会这样.

模板提取

section#main
  ul#todo-list
    each
      li class={isCompleted:completed}
        if isEditing
          input.edit
        else
          = input class='toggle' type='checkbox' checked=isCompleted
          label{action 'editTodo' on='doubleClick'}= title
          button.destroy
  input#toggle-all type='checkbox'
Run Code Online (Sandbox Code Playgroud)

控制器提取

`import Ember from 'ember'`

TodoController = Ember.Controller.extend
  actions:
    editTodo: ->
      @set 'isEditing', true

`export default TodoController`
Run Code Online (Sandbox Code Playgroud)

coffeescript ember.js emblem.js

5
推荐指数
1
解决办法
588
查看次数

AngularJS通过$ compile的动态内容范围未附加到控制器范围

当我通过具有指令的字符串生成新元素(这就是我需要编译的原因)并且该指令通过"="生成与控制器范围中的变量的关联时,我的控制器中的变量不与一个在指令中.

我创建了一个jsfiddle来显示"门"ng模型值应该与所有指令模型值相关联的示例.

看到这个小提琴:http://jsfiddle.net/aVJqU/2/

我注意到的另一件事是,从html中存在的元素运行的指令通过变量(控制器和指令)显示正确的关联.

html(有绑定的指令<door>):

<body ng-app="animateApp">
    <div ng-controller="tst">
        <h2> Controller with its model </h2>
        <input ng-model="doorval" type="text"> </input>
        {{doorval}}
        <h2> Directive render directly from the html </h2>
        <door doorvalue="doorval"></door> <key></key>
        <h2> Directives that are compiled </h2>
        <list-actions actions="actions"></list-actions>
    </div>
</body>
Run Code Online (Sandbox Code Playgroud)

这是指令:

animateAppModule.directive('door', function () {
    return {
        restrict: "E",
        scope: {
            doorvalue:"="
        },
        template: '<span>Open the door <input type="text" ng-model="doorvalue"> </input> {{doorvalue}}</span>',
        replace: true
    }
})
Run Code Online (Sandbox Code Playgroud)

这是控制器:

var animateAppModule = angular.module('animateApp', [])

animateAppModule.controller('tst', function …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive angularjs-scope angularjs-controller

4
推荐指数
1
解决办法
5354
查看次数