similar to: Model with self.abstract_class=true allows save method call

Displaying 20 results from an estimated 40000 matches similar to: "Model with self.abstract_class=true allows save method call"

2007 Oct 12
6
abstract_class... what exactly does it do
Hi, Does anyone know much about abstract_class? Does it actually prevent instances of the class from being created? Does it disable certain methods? I already know what it''s for, but I want to know what setting self.abstract_class=true actually does. The reason I ask is that I want to use it for a slightly unorthodox purpose. I want a class who''s only attributes are its
2006 Mar 14
4
What does the send() method do on a model object?
All, I did a scaffold for a model and I ended up with this code in list.rhtml: <% for column in TargetList.content_columns %> <td><%=h target_list.send(column.name) %></td> <% end %> Where is the "send" method and what does it do? I can''t find it on ActiveRecord::Base? I assume that it returns a value based on the column id but I
2012 Jul 25
0
Rails3-default_scope throws exception: undefined method abstract_class? for Object:Class
I would like to apply logical delete in my application(Instead of permanently deleting a record just have been marked as deleted). I have Added *available* column to all tables with default value *true*. Now I want common place to write the following code for all models. 1. Write the instance method which make ''available'' column value false when user clicks on
2006 Jun 27
5
Can''t call public application.rb method from ERb template
All, I have a left navigation partial that I want to dynamically generate CSS classes for based on the current controller action. In my ERb template, I have <DIV class="<%= get_menu_display_style(''login_form'') %>"> In application.rb, I have the method get_menu_display_style defined as: public def get_menu_display_style(action_requested)
2006 May 08
5
The true merit of non-memory based session stores
All, There is an assertion in AWDWR that the in-memory session store is "too simplistic." However, I find myself nudged in this direction by the need to keep a non-serializable model attribute available in my session and the relative pain of implementing either a custom serialization scheme for the model in question (or a custom caching mechanism so that I can store my attribute
2006 Apr 10
5
I have a Capistrano 1.1 patch - where does it go?
I have a patch for Capistrano 1.1 - how do I submit it? Wes -- Posted via http://www.ruby-forum.com/.
2006 Apr 12
2
IO.read fails on relative path in model object
All, I am attempting to do an IO.read call on a file inside of one of my model objects. I keep getting Errno::ENOENT The path I''m passing to IO.read is relative to RAILS_ROOT. Two questions: 1) This code was previously executing in my controller - it it significant that I moved it into my model? 2) Is there some way to verify which directory is the current directory for the
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 11
3
update_attributes and save!
I notice that ActiveRecord::Base.update_attributes() calls save(). What if I want to get an exception if the save fails? Is there a way to get the update_attributes() function plus the save! function? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Apr 17
3
Does render() have 2 be last statement in controller method?
I have a controller method that is attempting to do a render based on a potential error condition. So I have if (condition) render() else ..other code end ....other code in method Should I expect the render to take place immediately or does the render call not work because it isn''t the last statement in the method? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2007 Sep 29
8
Inheritance problem in model
Hello, I''ve got a problem with the inheritance as soon as I try to use it in a model. I''ve got plenty of items which can share a lot of code, so I created a class "Item", which inherits from ActiveRecord::Base, but because it''s not a "real item" but an interface, I set it abstract (writing abstract_class? method). Then I have all the differents
2006 Jul 06
4
ERb question: Embedding <%= %> in helper method calls
I had a situation where I wanted to use a <%= %> (scriptlet) in my text_field call to set the "disabled" attribute on the text field, like so: <%= text_field(:current_job, ''removeLinkPos'', :value => '''', :id => ''offset'', :maxlength => 2, :disabled => <%= sometest ? ''true'' :
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 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 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 May 08
1
Handling "unmarshalable" model object attributes
All, I have an attribute on one of my model objects that cannot be serialized because it contains a Proc. Is there a way for me to mark this attribute as "not to be serialized/unserialized" so that session marshaling/unmarshaling won''t fail? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
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 Mar 28
1
Model attributes that are not backed by persistent storage
I have a model object that I would like to add an attribute to. It''s an array of other objects. If I do attr_accessor :local_image_tags should I then be able to assign to object.local_image_tags or read from object.local_image_tags without incident? Is ActiveRecord going to assume that there is a table behind these guys? If so, how do I indicate that these attributes are not
2006 Aug 10
3
Want to use a view helper (TextHelper) in a model class
I have a model that deals with HTML and I want to use the text_helper.sanitize method to strip the HTML of Javascript. However, it doesn''t appear that I can get easy access to the text_helper methods from within a model. Anyone have any suggestions for how to do this? In general, I think that there are some ActionView helpers which are generic enough to want to use in a model class.