Displaying 20 results from an estimated 5000 matches similar to: "can't modify frozen hash"
2009 Jun 22
1
getting error can't modify frozen hash
Hi,
When I upgraded my rails application to rails 2.3.2 I am getting
error ''can''t modify frozen hash'' on using
@something.update_attribute(params[:something]).
Can anyone help me who is familiarize with this bug?
Thanks,
2006 Dec 08
9
How to update partial attributes of a object from a form?
I have a user table, and it has forty columns, including name, gender,
address, email, phone...
So my @user object will have forty attributes.
I divide these attributes into 4 groups... namely ''general info'',
''personal info'', ''contact info''... and I make separate forms to edit
these 4 different group attributes.
The problem is when I update
2011 May 21
1
Consequences of overriding update_attribute to force validation?
I know the debate of whether this should validate has been rehashed
many times. My question is, what are the consequences of overriding
this method to force validation? Will this break fundamental things?
Will it break plugins? Is there a reason not to have a strict
validation option?
In my code I will never use this as I consider it a terribly broken
method, but some gems use it and in one case
2006 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two 
password-attributes in my User model:
attr_accessor :password, :password_confirmation
I have validations on these attributes, and I need them to work both on 
create and update, since I have pages for changing and resetting the 
password.
Now when I want to update just the user''s login name, I guess I have the 
next
2008 Jun 13
1
TypeError (can't modify frozen hash) - Production Mode Only
Well, I''ve been testing out my code in production mode, in anticipation
of being able to show off my site soon.  Unfortunately, all is not going
as expected.  Production mode... well, its behaving differently than
development did.  I''ve already had login validation issues, and now it
seems that my PM system is broken.
If a user enters a non-existent username as a recipient of a
2007 Jan 10
6
Updating an attribute in db
Hello
I am a Ruby newbie, thus a rather simple question.
My list view shows table records and enables user to click a button in
order to change value of one attribute in given record. I use this code
to invoke a method from controller:
<%= button_to "Change", { :action => "edit", :id => prog.id_prog } %>
My method looks like this (just a simple one - to set the
2006 Jan 23
3
Clearing a file_column-type field
So I am now able to set/upload an image to my app using file_column, 
with a little bit of a change to the code.
I can change the image using an Edit page, but I''m trying to figure out 
what to do if the user wants to remove the image. I tried adding a 
Remove Image link in my list, but I''m not sure what to do in the 
remove_image method in my controller. I tried setting the
2006 Jan 17
2
update_attribute and validations
Just in case it saves someone else the several hours of insanity I just 
went through, update_attributes will not save unless the model 
validations are satisfied, but update_attribute (the singular form) 
will save the attribute to the database even if the model validations 
would fail!
This appears to be a feature, not a bug 
(http://api.rubyonrails.com/classes/ActiveRecord/Base.html) although
2009 Jan 18
2
after_save -- stack level too deep
Hi all,
I''m running into a brick wall trying to figure out my problem here.  I
have a model that has a boolean property called "paid".  I''d like to
add the following to my model:
def after_save
  self.amount == self.splits.sum(:amount) ? self.update_attribute
(:paid, true) : self.update_attribute(:paid, false)
end
The problem is, when I do this I get an error that
2011 Aug 14
5
Puzzled with form on multiple table rows
I''ve got a table of events, and each event has a boolean attribute
is_ten_event.
On each row of the table is a chekbox to edit the value of is_ten_event,
so that multiple rows can be edited with one submit.
In order to allow boxes to be un-checked as well, the logic in the
controller works like this
get array of events from checkboxes that are ticked.
make all events.is_ten_event =
2006 Feb 27
4
update_attribute with Validation?
Does anyone know of a way to update individual attributes with 
validation? update_attribute disables the validation checks in the 
record model, so I''m wondering if there''s a workaround for this.
In my application, I want to allow the user to update some or all the 
attributes without having to enter :password and :password_confirmation, 
both of which are subject to
2009 Jun 22
4
modal validation not works
Hi everyone,
i have 20 fields in users table.
in my admin profile module the admin can modify his infomation.
but only 12 fields he can able to modify.
so in my controller
if params[ :profileinfo ][:first_name]
    @profileinfo.update_attribute(:first_name,params[ :profileinfo
][:first_name])
end
the above simply saves what i enter into the field.why it doesnot
consider the modelvalidation.
2006 Apr 14
2
spot the error (I can''t, I''m new)
I have a form that I want to use to update multiple
objects.  In the controller,
   @grades = Grade.find(params[:grade].keys)
   @grades.each_with_index do |grade, i|
     grade.update_attribute(params[:grade][i])
   end  
   all_valid = @grades.inject(true) {|memo, c|
c.valid? && memo }
this doesn''t update the attributes as I would expect. 
(I would just use 
2008 Aug 25
2
to catch exception from update_attribute
Hi
begin
       ActiveRecord::Base.transaction do
         pb_status_history = ProblemStatusHistory.new
         pb_status_history.problem_id = @problem.id
         pb_status_history.problem_status_id =
@problem.problem_status_id
         pb_status_history.save!
         ret_val=@problem.update_attribute("problem_status_id",''ab'')
         if ret_val==false
          
2006 May 02
9
Updating only one field
At present, I use an update like this to set the user''s last login time:
authenticated_user.update_attribute(:last_login, Time.now)
However, this calls the following, updating all fields:
UPDATE users SET `last_login` = ''2006-05-02 13:27:41'', `hashed_password` 
= ....
Is there any way I can tell ActionRecord to only update the one field? 
I don''t really want
2011 May 08
1
Transaction - but no rollback?
Hello,
I''m having trouble with transactions with rails 3.0.3 and mysql 5. I''d
like to import data etl-batch-style:
class Job < ActiveRecord::Base
  # ...
  def perform_etl
    connection.transaction do
      extract # some connection.execute / job.update_attribute stuff
      transform # some connection.execute / job.update_attribute stuff
    end
  end
  #...
end
2008 Jun 16
2
call_backs Is it?
Hi
   I have the models
1.ServiceDeskTicket with fields
   id --- number --- service_desk_status_id -- created_on -- updated_on
etc
2.ServiceDeskActivity  with fields
   id -- service_desk_ticket_id -- description -- created_on --
updated_on
3.ServiceDeskAttachment
   id -- service_desk_ticket_id -- attachment  -- created_on --
updated_on
     Relations as
   ServiceDeskticket has_many
2006 Jun 27
4
File Column has me stumped
I have an existing entry in my DB under the "users" table that has a 
column name "pic". I have a file column field when a new user signs up, 
and it work great. I am now trying to give existing users the ability to 
add or change their "pic". But, no matter what I do the entry comes up 
blank. Here''s what I have so far:
View:
<%= start_form_tag ({:action
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture- 
driven way of spec-ing or mocking. How the heck to you mock this so  
the code at line (2) and (4) work right? I''m still struggling with  
mocks but it seems like this can be done. Forgive the naivety of this  
question.
1.  def change_quantity
2.    @line_item = LineItem.find_by_id(params[:id])
3.    unless
2005 Feb 12
3
ActiveRecord not updating record
Hi,
I''m having some problems using ActiveRecord to update records in a
sqlite database.  This isn''t exactly as rails question, since I''m
doing this initial import outside of rails, but I''m hoping someone
hear might have an idea as to what my problem is.
The basic problem is with the following code (which is run in a big loop)
m = Movie.find_by_title_and_year