状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串.
我已经测试了一个看起来很漂亮的但是效果不好的.它是'挑剔的颜色',它托管在这个存储库中:https://github.com/Astorsoft/picky-color.在这里,我打开一个关于它的一些问题的问题.
问题:请建议我在Rails 3应用程序中使用一些颜色选择器.
我已经在Mac上工作了一个多月,在此之前我一直在使用Windows并写了一个.bat文件来运行一些其他的小.bat文件来启动MongoDB,启动livereload,rails服务器和一个rails console.它最后推出了e-texteditor,它打开了rails dir作为一个项目.
我希望这是一个正确的地方,而不是超级用户.那么在Mac上自动化这些东西的一种方法是什么? - 目前,我启动了1个带有4个选项卡的终端窗口.tab 1运行'mongod',tab 2运行'rails s',tab 3运行'guard start',tab 4运行'rails c'.然后我打开另一个标签然后"交配".
我正在进行一个checkers实现,我有几十个容易测试的方法,但我不知道如何测试我的主#play_game方法.我的大多数方法都很容易确定输入和输出,因此很容易测试,这种方法是多方面的,并且实际上没有容易辨别的输出.这是代码:
def play_game
puts @gui.intro
while(game_over? == false)
message = nil
@gui.render_board(@board)
@gui.move_request
player_input = gets
coordinates = UserInput.translate_move_request_to_coordinates(player_input)
message = MoveCheck.move_validator(coordinates[0], coordinates[1], coordinates[2], coordinates[3])
puts message unless (message.nil? or message == "jumping move")
if(message == nil or message == "jumping move")
@current_player = switch_player unless (message == "jumping move" and jump_available? == true)
end
end
puts @gui.display_game_ending_message
end
Run Code Online (Sandbox Code Playgroud)
那么,如何进行测试(使用RSpec的),或者我应该不用担心,真正对我,否则全面的测试?
在工作中,我很遗憾地被迫使用Windows.我对gVim提供的字体选择感到不满(阅读:愤怒),我想把它改成我在家里的开发电脑上使用的字体.
但是,当涉及到set guifont =选项的可用内容时,gVim的选项有限.即使我知道有问题的字体对于VIM是很好的,因为我在其他地方使用它,我不知道如何添加到可用字体列表,即使我已经在这台机器上安装它,我找不到这个信息随处可见
有没有人对此有任何见解?我真的不明白为什么我不能把guifont设置为任何等宽字体我该死的,而不是gVim认为最好的.
我有一些模板文件,我想在我的rails应用程序中使用.我想知道给出两个场景的位置(在哪个目录下):
我正在为我的模型添加一个counter_cache:
用户(id,org_id)Orgs(id,users_count)
但是得到以下错误: ArgumentError (Unknown key(s): counter_cache):
class Org < ActiveRecord::Base
has_many :users, :counter_cache => true
class User < ActiveRecord::Base
belongs_to :org
Run Code Online (Sandbox Code Playgroud)
什么设置错误的任何想法.我想Org.users_count为该组织中的#个用户返回counter_cache?
我应该如何在rails 3 app中创建一个安静的API?另外我想知道是否有一种很好的方法来实现restful身份验证
ruby api restful-authentication ruby-on-rails-plugins ruby-on-rails-3
我有这个代码:
var tmp=$(this).attr('id').split("_");
Run Code Online (Sandbox Code Playgroud)
并且我想在分割后将tmp存储在tmp第二个值上.所以如果$(this).attr('id')="hello_marco"我想在tmp中存储值marco,而不是数组.
当然,我想直接在一行代码中完成它,而不是先存储数组并使用array [1]访问它.
JS/Jquery有可能吗?
我正在开发一个处理公共区域的rails应用程序(截至今天,静态页面),以及具有身份验证等的私有空间.这两个都是独立开发的.第一个是手工制作的风格,后者使用twitter bootstrap.
在生产中,rails将我的资产编译成一个文件,并且一些样式是冲突的,导致公共区域具有Twitter Bootstrap的一些元素......不是我想要的.
有没有办法配置资产管道,所以当它编译时,有两个输出?经典的application.css和front.css?
我一直在成功地遵循Rails教程3,直到我进入第7章并实现了用户模型,现在我的rspec一直在失败.
这是我的user.rb文件输出
class User < ActiveRecord::Base
attr_accessible :name, :email
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :name, :presence => true,
:length => { :maximum => 50 }
validates :email, :presence => true,
:format => { :with => email_regex },
:uniqueness => { :case_sensitive => false }
validates :password, :presence => true,
:confirmation => true,
:length => { :within => 6..40 }
before_save :encrypt_password
# Return tue if the user's password matches the submitted password.
def has_password?(submitted_password)
encrypted_password == encrypt(submitted_password)
end
def self.authenticate(email, submitted_password) …Run Code Online (Sandbox Code Playgroud) ruby ×4
api ×1
automation ×1
color-picker ×1
file ×1
file-upload ×1
javascript ×1
jquery ×1
macos ×1
rgb ×1
rspec ×1
testing ×1
vim ×1