similar to: Rendering collections

Displaying 20 results from an estimated 30000 matches similar to: "Rendering collections"

2006 Mar 19
1
Rendering Partials w/Collections - is there a way to find the position?
This seems obvious, but I wasn''t able to find info on it easily. If you are rendering a partial from a collection: <%= render :partial => ''message'', :collection => @messages %> Is there a way inside the partial to tell what item in the collection you are on? For example, if I am in the first element in the collection, I want to do something different?
2009 Jan 21
1
AR to_xml problem with associations, Builder::XmlMarkup#to_a
When I do a to_xml(with a block) on an association of a model I got a Builder::XmlMarkup#to_ary should return Array Example that does not work. @intervenant = Intervenant.find(params[:id]) output = @intervenant.to_xml( :skip_types => false, :dasherize => false) do |xml| @intervenant.individu.to_xml( :builder => xml, :skip_instruct => true, :skip_types => false,
2013 Jul 25
0
Reported timing aren't thread-safe, are they?
I was taking a look at the implementation for reporting the time spent on each part of an action processing. Rails, by default will report timing for the view and db (ActiveRecord). Both use class attributes for storing the timing (or accumulating them in the case of AR), which are shared among all threads. This is fine if you''re deploying using the fork approach, like done by
2007 Mar 01
2
FerretHash
Dave, thank you so much for the 0.11 release(s). You have solved many problems for me. As part of my appreciation for your good works, I am offering up for public consideration a silly little class that I wrote. (Code is below.) This class offers a simplified Hash-like interface to (a very restricted subset of) Ferret. Hence I call it FerretHash. FerretHash comes with its very own pet Ferret
2007 Apr 02
0
[937] trunk/wxsugar/lib/wx_sugar/enumerable_controls.rb: Initial commit of enumerable_controls.rb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding:
2007 Nov 29
3
Strange Array behaviour
I''m having a strange thing when using the Enumerable extensions for Rails: Have a look at the following code: class Invoice < ActiveRecord::Base has_many :invoice_lines def total invoice_lines.sum(&:total) end end class InvoiceLine < ActiveRecord::Base belongs_to :invoice def total amount * price end end Now, when calling invoice.total, I get wrong
2006 May 22
2
[vpim] Some small rrule.rb changes
Quoting cosmin at speakeasy.net, on Sat, May 20, 2006 at 11:40:06AM -0700: > I did some changes to the rrule.rb. I needed some getters/setters for > each of the attributes from RRULE. Attached is the diff. If it makes > sense to you to be included in the lib, please do so. If you think > it''s worth to be included, I can add more validation to the setters. I
2010 May 28
2
Suggestion for improving value_to_boolean column conversion
Hi fantastic rails core developers. Speaking of version 2.3.5: I find it rather error_prone that values such that "some text" is silently converted to false when stored in a boolean DB field. Among other things it means that assign "some text" to boolean fields on a model will not generate any validation messages (it will silently be converted to false). I think it is like
2010 Sep 14
0
Model with method_missing - rails 3, ruby 1.9.2 raises exception
Say you have two models Post and Author. And Post has_many :authors Finally, method_missing is overridden in Author. Then if you do Post.limit(1).first << Author.limit(1).first You get an exception Author does not define :to_ary Or has there been a change in rails 3 that I have completely overlooked while migrating my app? -- You received this message because you are subscribed to
2013 Jan 31
2
CollectionAssociation shadows Enumerable#count
Hi all, I realize this behavior is by design, and in some respects the right thing to do. It also pre-dates the addition of Enumerable#count. I''m wondering, however, if it''s possible/desirable to allow the caller to access the Enumerable versions under certain conditions. I originally wrote the up as an issue, but was informed this would be the better venue. I''m
2013 Mar 28
1
undefined method 'sanitize_limit' for #<ActiveRecord::Relation:0x2aaaad35d720>
I am trying to upgrate rails from 3.0 to 3.1, while updating rails version I am getting following error rake aborted! undefined method `sanitize_limit'' for #<ActiveRecord::Relation:0x2aaaad35d720> /some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:460:in `method_missing''
2011 May 23
0
Fallback for partial_paths on rendering process
Hi, I have an application that uses single table inheritance. Very simple stuff: class Place < ActiveRecord::Base class City < Place lets say I have a City on the @place whenever I try using the render @place I will get an error, saying the templace cities/city doesn''t exist but I do have a places/place template. Is the any nice way to add this fallback for the base_class
2012 Jun 29
0
Can I make Rails update_attributes with nested form find existing records and add to collections instead of creating new ones?
Hi there, I''ve asked this question at stackoverflow.com http://stackoverflow.com/questions/11257662/can-i-make-rails-update-attributes-with-nested-form-find-existing-records-and-ad I haven''t seen a better answer than one I propose myself but I''d like to know if it''s possible to enhance accepts_nested_attribute_for to allow a find_or_create_by behavior for
2010 Aug 22
7
Rails 3: Error saving an object with no useful information
Hey, I''m kinda desperate cause I''m getting an error and have no idea how to fix this since it doesn''t give me any information hinting where the problem is: irb(main):054:0> reload!;User.last.save! Reloading... NameError: undefined local variable or method `to_ary'' for #<User:0x4ed5d20> from
2005 Nov 16
3
Association collections problems
Hi all! I find association collections to be quite hard to understand and use. I have a Leg class that has_many :choices, and a Choice class that belongs_to :leg. In a controller I want to update both a Leg and its Choices. If I do it like this: @leg.choices.update params[:choice].keys, params[:choice].values It updates the database directly (or more specifically only updates records that
2005 Dec 21
1
Are Ducks Hibernating ?
Dears, Remembering last value in a select box don''t work for me as : Controller : @years=(1970..2005).to_a Form: <%= select_tag "year", options_for_select( (2001..2005).to_a, @params[:year] ) %> I had to write <%= select_tag "year", options_for_select( (2001..2005).to_a, @params[:year].to_i ) %> for it works. Not important, but I''m
2006 Mar 20
2
Noob Understanding Collections
Okay, I''ve had some success rendering partials and felt I''d try something more interesting with collections. I have a query run by my model, which works. When I run it from the console I can see all of the data I want. However, bringing that into my view isn''t working the way I think. So obviously I''m thinking wrong, but I can''t see where my
2010 Jul 11
10
dependent support for has_many through?
Given the following class Programmer < ActiveRecord::Base has_many :assignments has_many :projects, :through => :assignments end if I call Programmer#projects.clear, it will delete_all the joining assignments; however, I have a situation where I''d like the assignments to get destroyed instead so that their after_destroy callbacks get called. It would be simple to
2006 Jan 13
1
Rendering an RJS template within another RJS template
Is there a way to render an RJS template within another? I''ve put my simplified code below. No errors are generated, but the partial isn''t rendered. I also tried using render :action => ''update_actions'' destroy.rjs--- page.visual_effect :fade, comment_container(@object.id.to_s) # update the number of comments(below is another rjs template) render :partial
2006 May 02
4
useful bit of code (hopefully)
Hi, I often find myself using bits of code like this inside ActiveRecord, perhaps it''s useful for others, or others can improve on it: ########### # fix user input before validating it before_validation :sanitize_input # santize input before actual validation is called # this uses the little methods defined below def sanitize_input trim %w(adres postcode woonplaats email naam