similar to: Creating nested hash from nested active record results

Displaying 20 results from an estimated 100 matches similar to: "Creating nested hash from nested active record results"

2012 Jan 25
4
serializable_hash and serializable_add_includes
I''m trying to write a helper method similar to attr_accessible but instead it will be used to whitelist which attributes are available for serialization (attr_serializable). My first attempt at this was to override serialized_hash and modify the :only option to include nothing but serializable attributes. I''m facing a problem when nested models are ''included''
2007 Feb 16
6
some fun functionality for all your specs
I''ve found these two snippets of code useful and would love some feedback. first, .should_have_valid_associations usage: context "A new Product" do specify "should have valid associations" do @product.should_have_valid_associations end end code: (thanks to Wilson/Defiler for converting to rspec) module Spec module Expectations module Should
2006 Jun 08
3
Relationship and reflection
Hello, I have a question. I would like to know if there is a way with the reflection and respond_to? to know if there is a relationship between tables. When I say that I mean if inside a model there is a Has_many or belongs_to declaration. Because I try to get this information dynamically, during the execution of a script. If someone has an idea even if it''s not with the reflection,
2012 Jan 17
4
Find all association methods
Hi all, I want to get all association methods in one single model.... Any default method is provided by Active Record ??? i am using ruby 1.9.3 and rails 3.1.3 Please reply me .... Thanks, kingston.s -- 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
2006 Apr 19
2
Using Reflections to find out ActiveRecord class association
I want to find out what are the associations with another active record class. So If my class is as below: Class Component < ActiveRecord::Base has_many :branches end class Branch < ActiveRecord::Base belongs_to :component end and then I do Component.reflections[:branches].active_record I would expect that to be Branch but it is in fact Component. The inspection of
2007 Aug 14
2
Finding a models asscoations
Hi, I cant seem to find the answer to this anywhere so any help/advice is appreciated. Each project has one risk and a risk has a number of has/one belongs to assocations. So what i want to do is in my code loop through all the associations for a risk and display some field information from each as they are pretty similar. So somehting like <% for model_association in project.risks %>
2006 Apr 01
7
Any way around AssociationTypeMismatch?
I want to have popup menus and check boxes in my forms to let users select associated objects. In the form I''m working on, the object "belongs_to" another type of object which is selected from a popup menu. The id of the chosen object(s) for association is passed back in the parameter hash, but when rails creates a new object from this parameter hash, I get a
2006 Aug 12
5
Administrative Console Screencast
The first administrative console screencast is now available at: http://screencasts.visualjquery.com/demo1/ I''ve posted a bunch about the Admin Console, but it''s essentially an automated scaffold that works as an engine. The screencast is a quick overview of the minor things you''ll need to do in models, environment.rb, and others, as well as ::drumroll:: a demo of
2011 Jul 14
1
rails 3.0.9 ArgumentError (redundant UTF-8 sequence):
Hi guys, I have a simple controller def gmap @intentsearches = Intentsearch.all logger.info @intentsearches respond_to do |format| format.html {render :gmap} format.xml {render :xml => @intentsearches } format.json { render :json => @intentsearches } end end and want a json response, but i do get the following error Completed 500 Internal
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2013 Feb 01
0
Add a customer renderer but I get missing template
Hi, I''m trying to include the support of Msgpack<https://github.com/msgpack/msgpack-ruby> in Rails 3.2 but when I try to return a mpac response, I get an error concerning a missing template. My renderer: Mime::Type.register ''application/x-mpac'', :mpac ActionController::Renderers.add :mpac do |mpac, options| self.content_type ||= Mime::MPAC
2006 Jul 27
9
Introspecting validates_presence_of
Hello people, I''d like to detect whether an attribute of a model has vaildates_presence_of applied to it so I can automatically apply a mandatory (*) to the field...it doesn''t look easy...any ideas? Cheers, -- Dan Webb http://www.danwebb.net
2006 Mar 13
2
Prototype ajax/javascript q
I''m trying to send to my application the coords x,y on an "input type image" in a html form, but x,y variables are not present in the POST_DATA (are not submitted). Any other field (hidden inputs) are being sent when I click on the image input form field. I use rails 1.0 and prototype 1.4, browsers Seamonkey 2.0, Firefox 1.x and Konqueror, Linux, and I''m just a
2007 Oct 15
3
JavaScript error after including Prototype library
Hello, I''ve started seeing this error after including Prototype: Form.Element.Serializers[method] is not a function http://qaslweb1.crossmediaservices.com/shoplocal/scripts/prototype.js Line 2754 You should be able to see this error, using either Firefox or IE, when browsing to: http://qaslweb1.crossmediaservices.com/ Any ideas? Since this is a version of our original site rebranded
2012 Oct 01
1
active_model_serializers, more than one level deep of associations, specifying serializers per association
I am assuming this an appropriate place to discuss this, but if it isn''t my apologies- just let me know. Just a Rails 4-ish thing. Am attempting to pull AMS (active_model_serializers), strong_parameters, and the "permitter" strategy that Adam Hawkins is using: http://broadcastingadam.com/2012/07/parameter_authorization_in_rails_apis/ Code so far is here (in the
2006 Apr 07
2
Prototype 1.5.0_rc0 breaks my Form.serialize
Cheers, Prototype 1.5.0_rc0 breaks backwards compatability with this diff in Form.Element.Serializers: http://dev.rubyonrails.org/changeset/4147 I have explicit value="" in my options and now I get the text submitted. E.g. <select id="foo"> <option value="">Please select a value</option> </option value="1">Nr.
2012 Jun 21
1
ActiveModel::Serializers::JSON support arbitrary keys
Is there a reason why AM:S doesn''t support arbitrary keys to serialization? I can see a lot of uses cases where arbitrary keys could come handy. Right now, if one tries to do it, AM:S checks if the keys match a method of the model and raises exception if it can''t find any. class Client < ActiveRecordBase attr_accessible :name, :address, as: :creator include
2009 Jul 21
2
Odd coefficent behavior
Why are my coefficients getting appended with a 1? It borks a match I do later against the original list that doesn't have the random 1 added to the end. > linearModel[[1]] Call: lm(formula = modelSource ~ +UNITBUILD + UNITDB + ITBUILD + ITDB + UATBUILD + UATDB + HOGANCODE + RCF + ReleaseST1 + ReleaseST2 + ReleaseBLA + Small.Bank.Acquisitions + HLY.NewYear + HLY.MLK + HLY.PRES +
2007 Nov 16
3
IE: error with Serializers[method] in getValue()
Hi, Version: prototype 1.6.0 I''m using the $F function to get the value of a field. It works fine in FireFox, but IE 6 and 7 are reporting "object does not support his property or method" (translated from german). In IE debugger it hightlights the line 3485: --- return Form.Element.Serializers[method](element); --- I searched the web, but this problem seems to be quite unique
2009 Apr 14
5
.GSM -> .WAV (or ,MP3) Conversion
Hey there, I'm trying to convert some call recordings from asterisk we have in .gsm format to something I can pipe through ffmpeg - wav would be good, mp3 would be amazing! I've been trying playing with sox but I don't seem to be getting too far with 1239101491.30.gsm -ql -r 64000 -t wav 1239101491.30.conv.wav resample as ffmpeg borks at it: tim at freee-meee:~/dmc/call