search for: attr_readonly

Displaying 9 results from an estimated 9 matches for "attr_readonly".

2009 Jul 02
1
Prevent attribute from being changed with "attr_readonly"
Is there a way to prevent an attribute from being changed from outside the class instance? So that after a record is created, the attribute can be read but cannot be changed from outside the class instance. At first glance, "attr_readonly" seems to be the solution. However, will "attr_readonly" also prevent the attribute from being changed even from inside the class? In other words, will the following method successfully change the values of attribute_a and attribute_b in model A? 1.Class A < ActiveRecord::Base...
2007 Nov 16
1
small patch for attr_readonly
A small patch to fix attr_readonly when used in conjunction with optimistic locking Please Review: http://dev.rubyonrails.org/ticket/10188 +1 if it works for you. nick. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core"...
2009 Jul 02
0
validates_uniqueness_of and attr_readonly
I notice that I always want to prevent the unique key of a table from being changed. Does that mean I always have to have attr_readonly right after validates_uniqueness_of ? Is there a single function that replaces both of these but has the same affect? Thanks. -------------------------------------------------------------------------------- Developing with Rails 2.3.2; Ruby 1.8.7 (2009-04-08 patchlevel 160) [powerpc-darwin9] --...
2009 Mar 02
0
Implementing conditional read-only attributes of ActiveRecord objects
Hello, my goal is to implement the option of specifying a condition in attr_protected, attr_readonly and possibly other attribute methods in ActiveRecord objects. Rationale (example): class User < AR:Base # User should not be able to modify fields any more once they have been verified attr_readonly :firstname, :lastname, :gender_id, :birthdate, :if => :passport_verified? # ... end o...
2007 Dec 16
4
Make AR setter methods private?
Hi, I have a AR model that I want to limit changes to be only via instance methods that I''ve added. How do I prevent my other sw from setting the instance''s attributes? I know about #attr_protected and #attr_readonly. But the first leaves the individual setters as they were and the second stops all changes. I want something like "attr_private" Thoughts? Thanks, Larry -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because...
2009 Jul 04
12
save! not allowed after validates_uniqueness
I have this in a model validates_uniqueness_of :aspect, :scope => :user_id In an instance method of the same model I have "save!" but I don''t touch the :aspect attribute in that instance method at all. Whenever that save! command is run however I get this error: ActiveRecord::RecordInvalid: Validation failed: Aspect has already been taken I don''t
2007 Jan 26
7
How to protect attributes from being updated?
Hi! I''m new to Rails! Rails rox! 1 quesion so far: I have :email attribute in User model. I dont'' want :email to allow to be updated. How do i do this with Rails? Do I have to implement required validation manually? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2007 Dec 27
4
Lost connection..
Short update: It seems that the workers go into some state in which they do not have a correct Rails environment (or db connection). When they enter this state it goes wrong all the time :( Joost Hietbrink (YelloYello) wrote: > Hi all, > > We''re experiencing some problems with Backgroundrb. > > Why is "# master_reactor_instance.result_hash = {}" commented in
2007 May 21
7
How do I stop a column being updated by model.save?
One of my models has a column that is updated very frequently from a separate process, so it is important that when a record is saved in rails, this column should be left alone. In the update method of the controller I have: @record = MyModel.find(params[:id]) @record.update_attributes(params[:my_model]) params[:my_model] doesn''t have a reference to the column I''m talking