similar to: Read-Only Model Attributes AFTER creation?

Displaying 20 results from an estimated 3000 matches similar to: "Read-Only Model Attributes AFTER creation?"

2006 Mar 23
1
handle multiple lists: move an item from one list to another
How do I manage multiple lists? This is what I need. Sometimes an item needs to be moved from one list to another. class Item < ActiveRecord::Base belongs_to :group acts_as_list :scope => :group end class Group < ActiveRecord::Base has_many :items, :order => "position" end Now, sometimes, I may need to change an item from one group to another. But when I do that,
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 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:
2006 Jul 30
1
Bug? find_by_id(nil) returns object just created
Tried to submit a ticket in Trac, but it reported an error... Doing a Model.find_by_id(nil) after creating an object of type Model returns that object -- and the next time, returns nil. It should always return nil. For example, Step 1. Create an object: >> Foo.create(:name => "bar") => #<Foo:0x2aaaac3ade20 @new_record=false,
2008 Jan 01
2
Easiest defense against SQL injection in object creation?
I''ve been scouring the web for suggested Rails defenses against SQL injection, but I haven''t found much on the object creation part. Certainly using attr_protected, etc., is a good way to prevent unwanted fields from being modified on the new object (if you''re passing a hash as creation parameters), but what about escaping the POSTed info before saving? Couldn''t
2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
(I posted this as a bug in GitHub (https://github.com/rails/rails/issues/7018), but then someone there told me I should post it here, so here it is.) If you set attr_accessible on some properties in an ActiveRecord-descended class, and then attr_protected on others - the class becomes ''default-open'' - if any properties are missed or added later, they will be accessible by
2006 Apr 20
1
Permission denied using mount.cifs
I'm having a strange problem mounting a share from a Windows 2003 server using cifs: mount.cifs //osirus.ficticious.org/inetpub /inetpub -ouser=transfer,pass=dkfhjdjskd It comes back immediately with: mount error 13 = Permission denied Refer to the mount.cifs(8) manual page (e.g.man mount.cifs) However, the command below works. (abeit with about a 15 second wait before it comes back):
2007 Mar 07
4
Strange Problem With Unwanted, Transient Caching
Hello, I hope somebody can explain to me what''s going on here because I''m baffled! In a controller''s action I want to create a new order for a customer. Because I post back to the same action (not RESTful I know, but that''s for another day) I use code like this: def edit @order = Order.find_by_id(params[:id]) || Order.new ... end I
2006 Jun 27
3
find_by_id vs. find in postback action
I''m playing around with the Postback action recipe listed in the recipes book. Here is the default code given: def edit @recipe = Recipe.find_by_id(params[:id]) || Recipe.new if request.post? @recipe.attributes = params[:recipe] redirect_to :main_url and return if @recipe.save end end Here is what my code sort of ended up looking like, altho i''ve ripped it apart
2006 Apr 01
3
acts_as_list with scope : position update problem?
Hello, I''ve tried to set up a class with acts_as_list with a scope argument that restricts a list to records with the same foreign key. For example : database : CREATE TABLE `families` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '''', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; INSERT INTO
2012 Aug 01
2
'redirect_to' taking infinite loop.
Hi, The following controller method taking me into infinite loop. Once the update action completes I want to reload the ''index'' page. May I know why it is going into infinite loop? def update Device.find_by_id( params[:device_id] ).driver = ( params[:driver_id] == 0 ) ? nil : Driver.find_by_id( params[:driver_id] ) redirect_to :action => :index, :tab =>
2006 Jul 13
2
find_by_id(nil) does not always return nil
I have a model named User. When running this application from the console I can call User.find_by_id(nil) and it returns nil. When running this application during testing or through WEBrick or Mongrel calling User.find_by_id(nil) returns the newest record in the database. But it only does this the first time you call it with nil. The second time you call User.find_by_id(nil) it returns nil.
2006 Jun 19
4
DateTimes get converted to Dates in XML-RPC????
Hi all - I have written an XML-RPC app using action-web-service. Mostly works well. Except I just noticed that my :datetime types are coming back as :date types. That is, when in the console I query the record via Foo.find_by_id(123) I get back actual datetimes. If I then do it via XML-RPC, fetching that same record I get back dates (ie. hour/minute/second are set to 00:00:00) Any ideas?
2006 Jun 07
4
Question: coding protected methods
Apologies first, because I need to ramp up on Ruby and coding Ruby in Rails, however it''s my 3rd day with this beast :) so I''m asking : When I added protected methods to the model before it was like: protected method.................... end Would this be a valid way to write a protected method as well ?: attr_protected :column1, :column2 Perhaps this particular call
2007 Dec 04
1
spec''ing shared controller methods
I want to isolate and spec methods that are shared by controllers, and live in application.rb. Whereas I usually also provide examples in individual controllers that use these methods, not necessarily all the edge cases and I''d like to isolate the examples. This is the approach I''m taking (thanks to bryanl for suggestions and http://pastie.caboo.se/123626). WDYT? This
2006 Mar 01
2
Validating that a foreign key is present and ok
How do I validate that a model object''s attribute is a valid foreign key? The problem is, I can''t check if the attribute is a valid foreign key if the attribute doesn''t even exist. For example, every employee must be in a department. In the following code, if an employee''s department_id is not present then Department.find_by_id(department_id) might cause
2009 Jun 21
1
cannot do mass_assignment when inherited class ?
I got the following error when trying to create the elibrary instance (rdb:21) @elibrary = Elibrary.new(params[:elibrary]) RuntimeError Exception: Declare either attr_protected or attr_accessible for Elibrary, but not both. params : "elibrary"=>{"title"=>"bingo three", "short_description"=>"something new",
2008 Jan 13
3
right usage of bdrb
Hi, i''m going to implement a syndication-service, which will get lists in xml with some meta-data an enclosed video files, which will get encoded at the end. The syndication run will be startet every five minutes of a full hour. So i thought to build 4 Worker. One for checking which feeds to syndicate (syndication_worker) at a specific time, one for processing the list
2010 May 24
3
ActionController::DoubleRenderError
def dispfriends @myfriend=[] @myfriendlogin = [] i=0 @currentgroup = Group.find_by_id(params[:groupid]) puts @currentgroup.id @currentfriends= GroupFriend.find_all_by_user_id_and_group_id(current_user.id, @currentgroup.id) for n in @currentfriends @myfriend=n.friend_id @myusers = User.find_by_id(@myfriend) @myfriendlogin[i]=@myusers.login puts @myfriendlogin[i] i=i+1 respond_to do
2006 Jun 17
2
URL based on acts_as_tree using routes
Hi There! I''d like some feedback before I try to implement some funky rails routes based on an acts_as_tree model. I have a Page model that acts_as_tree. I''d like the URLs to look something like this: http://localhost/about-us/staff/jeff or, another example... http://localhost/what-we-do/products/our-great-cms/features/faqs/ So, as many sub-nodes the user creates,