similar to: multiple arguments to select

Displaying 20 results from an estimated 5000 matches similar to: "multiple arguments to select"

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:
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
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 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 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
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
2007 Nov 29
4
collection.build or collection.create gives "ArgumentError: wrong number of arguments (1 for 0)"
I have a Project that has_many Tasks. Tasks belongs to a Project. When I try the following: project = Project.new project.tasks.build I get: >> s = Project.new => #<Project:0x25f9e28 @attributes={"name"=>"", "end_at"=>nil, "updated_at"=>nil, "published_at"=>nil, "user_id"=>nil,
2012 Sep 20
2
append_features(mod)
append_features(mod) The documentation says: When this module is included in another, Ruby calls append_features in this module, passing it the receiving module in mod. Ruby’s default implementation is to add the constants, methods, and module variables of this module to mod if this module has not already been added to mod or one of its ancestors. See also Module#include. What if this module is
2011 Jun 27
2
insert value of primary key into another field before record is saved
Hey all, I created a seed task: def books! books = Book.where(:type_id => Type.find_by_name(''Fiction'')).order(''id'') books.each do |book| @books = 4.times.map do |i| subbook! "#{book.book_num}-#{i}".to_s, :book_state => BookState[:available].id, :book => book end end puts "log it:
2007 Jul 08
2
datetime_select, is creating an instance of the Time class
Hello It seems that datetime_select, is creating an instance of the Time class. Why would that be? I found this while building a site where people can create vigils (prayer vigils, peace vigils, etc). When I added a validation method that compared start_date to created_at, it generated the error: ArgumentError (comparison of Time with DateTime failed): I was able to put a breakpoint in the
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 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
2010 Sep 08
2
Rails 2 to Rails 3 - How to convert this sql query ?
Hello all, Can someone help me with this query ? Here is the query used in rails 2. The idea here is to obtain the top 10 widgets. Widget.find(:all, :select => ''widget_type_id, COUNT(widget_type_id) AS widgettypeid'', :group => ''widget_type_id'', :order => ''widgettypeid DESC'', :limit => 10) This is deprecated and i want to port it
2007 Sep 24
3
Oracle Date + RoR
Hi Experts, I''ve a model called Product where i''ve column called created_at, updated_at where i''ve made a query based on Oracle date format like date_of_created = ''23-SEP-07'' @product = Product.find(:all, :conditions => ["created_at=?", date_of_created]) but in view its empty. AND EXPERTS I''VE DATA WITH 24-SEP-07 FOR MORE
2010 Jan 22
11
Finding out where a variable is defined
I''m looking at code in a project. I have no clue what is being passed into the resource parameter: def read_authorized?(resource) if resource.respond_to? :user_read_authorized? resource.user_read_authorized? current_user else true end end Is there any kind of debugging feature I can run to see what gets passed into resource in this specific
2010 Jul 19
1
How to write your own created_at/updated_at?
I''m using Pfeed(http://github.com/parolkar/pfeed) plugin for User Activity Feeds. It creates PfeedItem model records and uses created_at field for a lot of stuff inside. Now I need to export/import those user logs. I do exporting to YAML. When I reconstruct PfeedItem AR object from YAML, it have real(old) creation time in created_at attribute. When I save this PfeedItem - there is new