similar to: append_features(mod)

Displaying 20 results from an estimated 1000 matches similar to: "append_features(mod)"

2012 Sep 22
4
Class, Module, Object
>> reload! Reloading... => true >> puts Class < Module true => nil >> puts Module < Class false => nil >> puts Module < Object true => nil >> puts Object < Module false => nil >> Object.parent => Object The above indicates that the Class object instance inherits from the Module object instance and the Module object instance
2012 Sep 08
4
dash symbol
In the example below, what is the dash doing between the class attribute and array: (field_helpers - [:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each do |selector| -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2012 Jan 01
4
Chronic parsing date range in console but not in application in rails 3
Hey all, Chronic will parse a date range in console: Chronic.parse(1/1/2011 - 1/1/2012, :guess => false) => 2012-01-01 12:00:00 -0500..2012-01-01 12:00:01 -0500 However, when I use logger to check if it''s parsing in application, it is not: logger.info "The value of history date is #{history_date}" => The value of history date is 1/1/2011 - 1/1/2012
2012 Jan 21
4
why doesn't an instance of Object get Class's new instance method?
"Object is the root of Ruby''s class hierarchy. Its methods are available to all classes unless explicitly overridden." Wouldn''t Class class be at the root of the class hierarchy? After all, look at this: 1.9.2p290 :006 > Object.instance_of? Class => true Object is an instance of class, after all we can use one of Class'' instance methods on Object:
2012 Sep 18
4
multiple modules defining same method included into a class
In Ruby, classes are never closed: you can always add methods to an existing class. This applies to the classes you write as well as the standard, built-in classes. All you have to do is open up a class definition for an existing class, and the new contents you specify will be added to whatever''s there. In the same regard, if module is used with the name of a pre-existing module that
2012 Sep 09
2
mattr_accessor inside a class
Rails extends Ruby with mattr_accessor (Module accessor). As Ruby''s attr_accessor generates getter/setter methods for instances, mattr_accessor provide getter/setter methods at the module level. In below example, you see that mattr_accessor declared in the class context of LookupContext. It''s declared in class, not module. However, modules are defined in LookupContext, for
2012 Sep 09
2
What module are the <% %> and <%= %> defined in?
What module of ActionView are the <% %> and <%= %> defined in? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2012 Sep 02
1
to_model
There''s a number of calls in the Rails source to convert_to_model, which takes an activerecord object instance: convert_to_model(object) Here''s the thing. All convert_to_model does is calls to_model, which returns self (the ActiveModel instance). Am I missing something here? Why call a method that returns the same thing? @user => #<User id: 3, name:
2010 Feb 10
7
undefined method join
Hey all, I get an undefined method `join'' for #<String NoMethodError. student.rb has_one :student_fail attr_accessor :student_fail_attribute #controller def student_fail @student = @student.find params[:id] def update_student_fail @student.build_student_fail params[:student][:student_fail_attribute] if @student.save #view form_for @student do |f|
2012 Sep 21
2
in Rails, what is the main (global) scope called?
For example, you see files called rails/actionpack/lib/action_controller/base.rb which adds methods and such to the open module ActionController. What scope is ActionController in? Is it just called the global scope? Obviously, there is namespace resolution lookup. And a good example of this is in the Base class of the same file. It references one module like this: AbstractController::Layouts
2012 Jan 22
4
undefined method `gsub!' for 2012-01-22 17:00:00 -0500..2012-01-23 00:00:00 -0500:Chronic::Span
Hey all, I am getting this error: NoMethodError (undefined method `gsub!'' for 2012-01-22 17:00:00 -0500..2012-01-23 00:00:00 -0500:Chronic::Span): in this code: date_range = Chronic.parse(the_date, :guess => false) reports.sum_distance_by_date(date_range).each do |d| u[:m] << d end def
2011 Nov 02
1
getting devise to return json data when signing out
Hi all, In curl (the command line program), I can successfully log a user in using devise: def create respond_to do |format| format.json { if user_signed_in? return render :json => {:success => true, :errors => ["Already logged in."]} end resource = warden.authenticate!(:scope => resource_name, :recall =>
2010 Jan 18
3
The role of self and :: within a method of a model
Hey all, I understand that a def self.abc, for example, is a class method, which allows you to call its contents by just referencing model.abc (rather than model.new.abc). However, what is its role when located in a method inside a model like in the code below. Also in the code below, you see :: located in the method. Isn''t that used for modules and namespaces? If so, why is it located
2013 Jun 08
1
ActiveSupport::Concern support Module#prepend?
I''ve monkey patched this behavior into a gem and I was wondering if core would be interested in a PR to add Module#prepend support to ActiveSupport#Concern. I''ll add tests of course. The code is here: https://github.com/dockyard/easy_auth/blob/master/lib/easy_auth/active_support/concern.rb My monkey patch work for what I''m trying to do but I suspect a better
2011 May 13
4
unexpected results when extending methods to class Class and class Object
Hey all, There''s a core Class class and core Object class in Ruby library: http://www.ruby-doc.org/core/classes/Object.html http://www.ruby-doc.org/core/classes/Class.html First, let''s resolve the simple distinction between an Object and Class as envisioned by Smalltalk but within the Ruby context: #A class is a template used to define methods and properties class Hello
2013 Apr 03
2
strange behavior with active relation any? method
In console, I run the following and any? returns true: drivers = Driver.select("drivers.*, drivers.id").joins([:reports, :driving_habits]).where("extract(MONTH FROM reports.time) = ? AND extract(YEAR FROM reports.time) = ?", 3, 2013).uniq.order("drivers.id asc").page(2).per(1) drivers.any? => true This correctly evaluates to true because the relation contains one
2012 Feb 04
3
the ^ and % operators in context
The % is modulus (remainder) operator and ^ is bitwise. In this context, we take a file, and go through each character and encrypt it. But why are the ^ and % operators used here: def encrypt(reader, writer) key_index = 0 while not reader.eof? clear_char = reader.getc encrypted_char = clear_char ^ @key[key_index] writer.putc(encrypted_char) key_index = (key_index +
2013 May 07
2
Net::HTTP
I''m looking at the documentation: http://ruby-doc.org/stdlib-2.0/libdoc/net/http/rdoc/Net/HTTP.html And I notice two uses of Net::HTTP. Both are using GET requests. But what''s the difference? When to use which? Net::HTTP.start(uri.host, uri.port) do |http| request = Net::HTTP::Get.new uri response = http.request request # Net::HTTPResponse object end uri =
2013 Apr 27
3
where exactly are gems?
when you add a gem to the Gemfile and then run bundle install, where does the command look for the gem? If you had "gem ''rails'', :git => ''github.com/rails/rails.git", I assume it would update your system .rvm gems directory with the latest github commits. But what is the default repository that bundler looks for gems? -- You received this message because
2013 May 18
3
You have already activated rake 10.0.4, but your Gemfile requires rake 10.0.3.
I''m careful to create separate gemsets for each project, so when I run bundle install, it only installs gems for that gemset. This way gems dont creep into the wrong projects. Now I just pulled a project from github. I made sure I was in the correct gemset, and then I run bundle install and it works fine. but then when I use rake to create the database "rake db:create". I get