Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Roman Budnikov's Profile

GitHub User: Supro

Site: rufolio.jivi.tv

Comments by Roman Budnikov

Avatar

Got bug when using #120 Thinking Sphinx and models what include concerns like in #398-service-objects

card.rb

ruby
# coding: utf-8
class Card < ActiveRecord::Base
  include Userable

  ...
  #Sphinx search
    define_index do
      indexes :name
      indexes :text
      has :card_way_id, :card_type_id, :card_mode_id
      set_property :delta => true
    end 
end

concerns/userable.rb

ruby
module Userable
  extend ActiveSupport::Concern

  included do
    attr_accessible :user_id

    belongs_to :user
        
    validates :user_id, presence: true
    validates :user_id, numericality: { only_integer: true },
                        if: lambda{|m| !m.user_id.nil? }
  end
end
ruby
Warning: Error loading /home/roma/rails/discount/app/models/concerns/userable.rb:
uninitialized constant Concerns::Userable
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in `each'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in `constantize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:64:in `block (2 levels) in load_models'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in `each'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in `block in load_models'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in `each'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in `load_models'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:15:in `prepare'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:81:in `block in context'
<internal:prelude>:10:in `synchronize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:78:in `context'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/active_record.rb:166:in `define_index'
/home/roma/rails/discount/app/models/card.rb:40:in `<class:Card>'
/home/roma/rails/discount/app/models/card.rb:2:in `<top (required)>'
(irb):1:in `irb_binding'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `catch'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `start'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
Avatar

Got bug when using #120 Thinking Sphinx and models what include concerns like in #398-service-objects

card.rb

ruby
# coding: utf-8
class Card < ActiveRecord::Base
  include Userable

  ...
  #Sphinx search
    define_index do
      indexes :name
      indexes :text
      has :card_way_id, :card_type_id, :card_mode_id
      set_property :delta => true
    end 
end

concerns/userable.rb

ruby
module Userable
  extend ActiveSupport::Concern

  included do
    attr_accessible :user_id

    belongs_to :user
        
    validates :user_id, presence: true
    validates :user_id, numericality: { only_integer: true },
                        if: lambda{|m| !m.user_id.nil? }
  end
end
ruby
Warning: Error loading /home/roma/rails/discount/app/models/concerns/userable.rb:
uninitialized constant Concerns::Userable
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in `each'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in `constantize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:64:in `block (2 levels) in load_models'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in `each'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in `block in load_models'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in `each'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in `load_models'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:15:in `prepare'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:81:in `block in context'
<internal:prelude>:10:in `synchronize'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:78:in `context'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/active_record.rb:166:in `define_index'
/home/roma/rails/discount/app/models/card.rb:40:in `<class:Card>'
/home/roma/rails/discount/app/models/card.rb:2:in `<top (required)>'
(irb):1:in `irb_binding'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `catch'
/home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `start'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
/home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'