ruby-on-rails-3.1

ActiveModel::SecurePassword undefined method `password_digest='

馋奶兔 提交于 2020-01-01 18:58:24
问题 I try to use rails 3.1 ActiveModel::SecurePassword by following http://bcardarella.com/post/4668842452/exploring-rails-3-1-activemodel-securepassword and I end up with red light ... user.rb class User < ActiveRecord::Base has_secure_password validates :password, :presence => { :on => :create } end factory.rb Factory.define :user do |f| f.email "foo@bar.com" f.password "foobar" f.password_confirmation { |u| u.password } end spec_user.rb describe User do it "should authenticate with matching

ActiveModel::SecurePassword undefined method `password_digest='

戏子无情 提交于 2020-01-01 18:55:09
问题 I try to use rails 3.1 ActiveModel::SecurePassword by following http://bcardarella.com/post/4668842452/exploring-rails-3-1-activemodel-securepassword and I end up with red light ... user.rb class User < ActiveRecord::Base has_secure_password validates :password, :presence => { :on => :create } end factory.rb Factory.define :user do |f| f.email "foo@bar.com" f.password "foobar" f.password_confirmation { |u| u.password } end spec_user.rb describe User do it "should authenticate with matching

Classes defined in CoffeeScript not found by Jasmine specs

我是研究僧i 提交于 2020-01-01 14:36:06
问题 I am building a backbone.js app on a Rails 3.1 back-end. I'm using CoffeeScript to write the backbone classes, and Jasmine (via jasmine-headless-webkit) for testing. Given the following (partial) tree: . ├── app │ ├── assets │ │ ├── javascripts │ │ │ └── views │ │ │ ├── avia_view.js.coffee ├── spec │ ├── javascripts │ │ └── views │ │ └── avia_view_spec.js.coffee ... I would expect avia_view_spec.js.coffee to know about Avia.AviaView , which is defined in avia_view.js.coffee . However, I get

Classes defined in CoffeeScript not found by Jasmine specs

不问归期 提交于 2020-01-01 14:34:28
问题 I am building a backbone.js app on a Rails 3.1 back-end. I'm using CoffeeScript to write the backbone classes, and Jasmine (via jasmine-headless-webkit) for testing. Given the following (partial) tree: . ├── app │ ├── assets │ │ ├── javascripts │ │ │ └── views │ │ │ ├── avia_view.js.coffee ├── spec │ ├── javascripts │ │ └── views │ │ └── avia_view_spec.js.coffee ... I would expect avia_view_spec.js.coffee to know about Avia.AviaView , which is defined in avia_view.js.coffee . However, I get

Ruby - Multiplication issue

不想你离开。 提交于 2020-01-01 12:27:10
问题 My output is like this - ruby-1.9.2-p290 :011 > 2.32 * 3 => 6.959999999999999 And I remember sometime back on another machine I had got it like.. 2.32 * 3 = 6 What is my mistake? Thanks a ton for reading this. :) 回答1: If you really want to round down to an integer then just (3 * 2.32).to_i but I think that's unlikely. Usually you just want to format the slightly imprecise floating point number to something like this "%0.2f" % (3 * 2.32) => "6.96" If you really want to work with the exact

Using the Bubble sort method for an array in Ruby [closed]

折月煮酒 提交于 2020-01-01 12:00:08
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'm trying to implement the Bubble sort method into an easy coding problem for Ruby, but I'm having some trouble. I understand the idea is to look at the value of the first element and compare it to the value of the second element and then swap them accordingly, but I can't seem

Rails, Ruby 1.9.3p0, and mysql gem

你离开我真会死。 提交于 2020-01-01 09:24:23
问题 I'm running CentOS6 and installed Ruby from source, along with Rails and some other staff. ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] rails -v Rails 3.1.3 Some gems: *** LOCAL GEMS *** actionmailer (3.1.3, 2.3.14) actionpack (3.1.3, 2.3.14) activemodel (3.1.3) activerecord (3.1.3, 2.3.14) activeresource (3.1.3, 2.3.14) activesupport (3.1.3, 2.3.14) archive-tar-minitar (0.5.2) arel (2.2.1) bigdecimal (1.1.0) bouncy-castle-java (1.5.0146.1) builder (3.0.0) bundler (1.0.21)

newbie: error message when 'rake -T'

為{幸葍}努か 提交于 2020-01-01 09:10:11
问题 I am using Ruby Enterprise Edition for my project. When I check all my rake task by run the command rake -T , I got the following error message: You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this. The error message implies that I can use bundle exec to solve the problem, but I am not sure how? So, how to get rid of this error message? ------------------------------ more --------------------------- I prefer to update my Gemfile

Initializing Instance Variable as an Array - Ruby

被刻印的时光 ゝ 提交于 2020-01-01 06:27:50
问题 I'm trying to initialize and instance variable as an array as follows: class Arch < ActiveRecord::Base attr_accessor :name1 def initialize @name1 = [] end def add_name1(t) @name1 << t end end When I try Arch.new in a console session I get (Object doesn't support #inspect). What's up? How do I make an instance array variable? I tried to follow this like so: class Arch < ActiveRecord::Base attr_accessor :name1 def after_initialize @name1 = [] end def add_name1(t) @name1 << t end end and my

Initializing Instance Variable as an Array - Ruby

徘徊边缘 提交于 2020-01-01 06:27:08
问题 I'm trying to initialize and instance variable as an array as follows: class Arch < ActiveRecord::Base attr_accessor :name1 def initialize @name1 = [] end def add_name1(t) @name1 << t end end When I try Arch.new in a console session I get (Object doesn't support #inspect). What's up? How do I make an instance array variable? I tried to follow this like so: class Arch < ActiveRecord::Base attr_accessor :name1 def after_initialize @name1 = [] end def add_name1(t) @name1 << t end end and my