similar to: How to get more informations about an association at runtime

Displaying 20 results from an estimated 800 matches similar to: "How to get more informations about an association at runtime"

2008 Jan 31
3
presenting validation errors via fbml?
Hi Facebookers, Is there a helper or suggested approach for presenting validation errors on an fbml form? Something to translate rails error markup to fbml:error markup? thanks Joel
2006 Jun 13
7
help with ''error_messages_for''
Greetings, I''m in the throws of deploying an app on site5, and I''m getting strange errors. I think I might need to understand how error_messages_for works. I get a pretty standard looking error: " You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occured while evaluating nil.errors Extracted
2006 Dec 12
2
Error message translation
I have a problem with translation of english phrase when an input error occurs. When I put: error_messages_for("registratie") above my view. I get the error: "xx errors prohibited this registratie from being saved". The problem now is, the site is for dutch customers and I would like to translate this to a dutch phrase. I know I can translate the individual fields with the
2006 Apr 06
3
Formating Float ActiveRecord attributes in text inputs
I have AMOUNT field that ActiveRecord maps to Float. Then I use text_field helper to generate text inputs on forms. Helper takes model object and attribute name and does not provide any formatting abilities, thus 2.40 is shown as 2.4 which is fine with floats but does not look good with currency. I have worked around this issue by adding amount_f attribute to the model that returns formatted
2009 Oct 15
4
Getting the object in fields_for
I''m using the fields_for helper with accepts_nested_attributes_for The System model has_many children. If I do this in my haml template: -form_for @system do |s| =s.text_field :name -s.fields_for :children do |child_fields| =child_fields.text_field :name all is fine. The fields_for iterates over all children and puts the correct data in the fields. But...what I
2006 Sep 12
2
accessing validates_... , :message => 'something'
Hi, i have a validates_something_of_something method in my User model...i added a :message => "you need to abcd" to the validation method, but when i try to access it through the <%= error_messages_for "user" %> it doesn''t give me any output... i was wondering whether there was a way to access all of the (:message => string) methods that are collected
2007 Jun 10
2
custom errors for validates_presence, etc..
I am trying to figure out how to customize the error messages when I use validates_presence_of. I am validating a user name and I use <%= error_messages_for ''user'' %> in my view to display the messages. I know you can customize in the model with :message =>''custom message'', but I am trying to get rid of the first part of the error message which is, 1
2005 Mar 09
9
Unit testing + instance variables
After *much* digging and playing around, I finally figured out how to unit test instance variables that are created by actions. It was more difficult than I expected. It seems like there should have been a more straight forward way to do this. Can someone enlighten me? A simplified and somewhat contrived example of what I am current doing: Thanks. Matt >> # My Controller of interest
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
2007 Dec 05
5
Active Record, Migration, and Translation
Hi, I think the columns and table in migration should be able to have an optional "display_name" set manually. Something like: create_table :people, {display_name => "Personne"} do |t| t.column :first_name :string, :display_name => "Prénom". end Let me explain my point of view: Rails is a framework made to write programs in English. You see it when you
2010 Oct 06
2
reflect_on_association method
Hi all, I am having trouble trying to use reflect_on_association method with given the simplified model: class Order < ActiveRecord::Base belongs_to :contractor, :class_name => "BusinessUnit" end I expected the reflect_on_association method to return associated_foreign_key "contractor_id" but it returns "business_unit_id": ruby-1.9.2-p0 >
2007 Jul 24
11
Mock or Stub strategy for validates_uniqueness_of
Hi, I''m a bit stuck with mocking a unit test of a join model with regards to a validates_uniqueness_of clause. I have class Book < AR:B has_many :clippings various validates_presence_of etc end class Clip < AR:B has_many :clippings various validates_presence_of etc end class Clipping < AR:B belongs_to :book belongs_to :clip validates_uniqueness_of :clip_id,
2006 Jul 18
2
Turn element hidden by default (ajax question)
(this is my first post on the ruby forum. If this is not the right place for this type of question please let me know). Ajax question I have a checkbox that toggles the visibility of another element (a text field) with the code: --- <p><label for="checkbox">Appear!</label> <%= check_box :object_name, :method, :onClick =>
2007 Apr 09
4
How do i switch off error wrapping for a specific field?
Hi, i have some issues with the default rails error wrapping. It wraps errors in a div with class ''fieldsWithError'', which is not good practice in my eyes. Adding a class ''error'' to the field would be much nicer. My solution to the problem: build your own FormBuilder. Funny enough, i found no (nice) possibility to switch error wrapping off while using the
2007 Aug 10
1
How to spec a model method
Still new to Specs... How do I create a spec to test a model method? Specifically, here is my spec: #testing model describe User do it "should have many user roles" do User.reflect_on_association(:user_roles).should_not be_nil end it "should have many roles though user roles" do User.reflect_on_association(:roles).should_not be_nil end it "should know
2006 May 14
4
searching on foreing keys
Hey all, I''m using a simple search function. It''s working great except for foreign keys. I have one table pets (id,name,owner_id) and another table people(id,name) owner_id being a foreign key of pet pointing to people name. here it is on the pet controller: @paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id like
2006 Apr 08
2
ActionView::Helpers::FormHelper instance methods should take an object reference rather than an object_name.
Hi ActionView::Helpers::FormHelper methods (e.g. #text_field, #check_box...) take object_name as an argument. From this argument they infer a name that is supposed to contains the reference to the relevant object. I can''t see why the FormHelper methods were designed that way. Compared to simply passing them a reference, the current way seems too complicated and an invitation to problems
2006 Feb 26
2
howto keep already entered form fields
Hi, is there a way to keep the already entered form fields when the form is re-displayed after some error has been detected and reported to the user via flash? Regards IJD -- Posted via http://www.ruby-forum.com/.
2006 May 29
2
Creating a new virtual field
Hello, I have a problem with one of my Rails-Application, I have a table and on this there is object_name and a object_nr, so i want to create a combination of both in the model for a collection box. I''ve tried something like this: def set_new_object_name objects = find(:all).to_new_object_name end def self.to_new_object_name self.new_object_name = self.object_nr + " -
2006 Mar 20
2
Rails Plugin to Help Debug Views
Hi, I just released a plugin to help debug views. The plugin makes it easy to add a button that will popup a new window that displays the following debug data; * Request Parameters * Session Variables * Flash Variables * Assigned Template Variables It was derived from code that traces back to Marten Veldthuis in Epilog. You can check out webpage and plugin via;