similar to: What is the best way to override an _entire_ AR::Errors msg?

Displaying 20 results from an estimated 10000 matches similar to: "What is the best way to override an _entire_ AR::Errors msg?"

2006 Jul 12
1
validate method not getting called?
Here''s a snippet of my model: validates_presence_of :from_name, :from_email, :reply_name, :reply_email, :eSubject protected def validate puts "Calling: #{target_list_ids}" errors.add_to_base("You must choose at least one target list for this job") if self.target_list_ids.nil? end It appears that the validates_presence_of are being called just fine,
2006 Jul 17
6
Best Practices: Splitting the "view model" from AR model
All, I''m starting to see view state information creeping into my model class. For example, I have text fields in my view that need to be set a certain way depending on whether or not a checkbox is checked. And while the values of these text fields ultimately do represent database columns that are related to the backing AR object, the text_field values also represent attributes on a
2006 Mar 20
5
Wrap error_messages_for() call when no instance var present
I am trying to put some smarts around a call to <%= error_messages_for %> so that when I first come into this page i.e. when my instance variable @target_list has not been defined yet, the page doesn''t break. I''m doing this: <% if @target_list? %> <%= error_messages_for ''target_list'' %> <% end %> I get a syntax error on line 1.
2006 Jul 14
2
Validation not executing on save - need help debugging
All, The validation on my object is not being triggered any more on the save action. I''m trying to debug it. In attempting to debug it, I''m trying to understand exactly what validates_presence_of does. Basically, I''m trying to see if for some reason, validates_presence_of doesn''t think my fields are blank now. I see from the API docs. that
2006 Aug 15
6
Theoretical: Should models be subclasses of AR or mix it in?
All, My apologies if this is a little long-winded and stream of consciousness-y :). SUMMARY: Why do we extend ActiveRecord instead of mixing it in to our model classes? Been thinking about my app''s models and starting to want to build something of a hierarchy. I have some commonality across 3 of my model classes and I''d liek to aggregate the behavior in a superclass.
2006 Mar 20
8
Best way to organize non-controller logic???
I don''t want to put certain code in my controller because I think it makes things more confusing. What is the best way to manage business logic such that it doesn''t end up in the controller? Basically, where should I put my regular utility classes and backing objects that may not be models? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Jul 03
4
text_field doesn''t call overridden ActiveRecord getters
All, In a template, I have <%= text_field :target_list, :DateReceived, { :title => ''uploaded_at'', :class => ''target_list_info'', :disabled => ''true'' } %> Here is the DateReceived method on my
2006 May 16
3
Best way to handle namespace collisions?
All, I have a little namespace collision here. I am trying to use both RubyfulSoup (an HTML parser - which I highly recommend by the way) and the ActionView::Helpers::TextHelper class. Within the TextHelper class, there''s an attempt to create a new "Tag" object. However, Tag is also defined in the RubyfulSoup gem and it is _this_ Tag class whose initialize method is
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All, I''m having a hell of a time figuring out what is going on here. I''m trying to override one of my getters so that I can format it a certain way in my form. But I can''t seem to get text_field to call the appropriate method on my object. So here''s my getter: public def FAX fax = read_attribute(:FAX) puts fax
2006 Mar 20
4
Ajax.Request w/standard redirect doesn''t render
I am doing an Ajax call in my page to a controller method like so: new Ajax.Request(''<%= url_for(:action => "target_list_add" )%>'', { asynchronous:true });" In my controller method "target_list_add", I do something and then I say: redirect_to( :action => ''target_list_upload'', :layout => false ) I know for certain
2006 May 25
5
rake migrate VERSION=0 doesn''t appear to execute
All, I''ve decided to jump into Migrations before I get too far along on the DB side of things. I already have some tables built, and I went ahead and built the migration that would have created them from scratch, and I made sure that there was a self.down section to drop them. I wanted to verify that I could roll back so I figured I would use rake to drop these pre-existing tables
2008 Nov 06
3
Verifying some understanding about manipulating DB data in before/after callbacks in RSpec
We had an after(:each) callback that looked like this: PurchaseOrder.find(:all).each {|po| DraftInvoice.find_all_by_po_number(po.po_number).each {|di| di.destroy}} which we were hoping would reset some purchase order data in a certain way. However, because we have "self.use_transactional_fixtures = true" set in test_helper.rb, this code was never getting committed. So, I just
2006 Jun 22
4
ADVICE: Generating unique identifiers for later DB insertion
All, I have an ActiveRecord object that I need to be able to uniquely identify _before_ I actually save the object (I may not end up saving the object based on conditions). This is because I want to use the ID in another context (a file name in the filesystem). Depending on conditions, I may or may not need to do a lot of stuff between the time that I generate the object ID and actually
2006 Mar 14
8
The RoR equivalent of out.write() in JSP?
All, In JSP, I can output strings in the Web page by either <%= foo %> //foo is a string or returns a string or <% out.write("test") %> //write directly to the output stream. What is the method of "writing to the output stream" in RoR? Basically, what is the equivalent of out.write()? I have an if then statement that I want to put around a call to h
2006 Mar 28
3
AJAX/CSS issue (more UI focused)
All, This isn''t strictly a problem or issue with RoR but I wondered if someone might have some insight. I have a DIV on a page which I am using to "preview" the contents of a URL provided by the user. Basically, when the user clicks on a link, I do an AJAX call to an action which uses Net::HTTP to request the URL in question and then update the DIVs innerHTML attribute
2006 May 10
2
What is wrong with this initialize method (code example)?
Here is my class: class Document < ActiveRecord::Base public def initialize puts "Called initialize..." super.initialize end This generates the following 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.initialize WTF? Wes -- Posted via
2006 Jul 05
7
HABTM join table has an "ID" column - is this an issue?
All, I''m building model objects for existing tables that I cannot modify. In AWDWR, Dave says "Note that our join table has no id column...The second reason for not including an id column in the join table is that AR automatically includes all columns from the join tables when accessing rows using it. If the join table included a column called id, its id would overwrite the id
2006 May 01
4
URL encoding in Rails?
Simple question: How does one do URL encoding in Ruby/Rails? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Jul 05
3
PLUGIN newbie: How do I use an installed plugin
All, I''ve downloaded and installed a plugin into my vendor directory. How do I then take advantage of it? It has an init.rb file which has the appropriate require. What do I need to do to make sure that the plugin code gets loaded? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Apr 18
4
Security considerations with displaying uploaded HTML
I have an application where I am allowing users to upload (or refer the app. to) arbritrary HTML that I am (currently) displaying in an IFRAME on a page. The users will be authenticated so it''s not open to the entire universe. I was always uneasy with this, but after reading the security chapter of AWDWR, I am even more concerned. What kinds of applications do people have out there