Questions tagged [update-attribute]

27 questions
13
votes
0 answers

Readonly error when running a Rails 3 migration with update_attribute

I'm trying to add a counter_cache and this Rails 3 migration is giving me an error I just can't seem to resolve. The migration is class AddItemsCountToStore < ActiveRecord::Migration def self.up add_column :stores, :items_count,…
Adam Mikulasev
  • 615
  • 1
  • 5
  • 12
6
votes
1 answer

Nifi - how to add days to the date

Could somebody tell me how I can add x number of days to a date attribute that is in the format ("yyyy-MM-dd") in Nifi.
John
  • 187
  • 1
  • 3
  • 12
6
votes
2 answers

What does `update_attribute` return if it fails?

I have following piece of code @user = User.find(params[:id]) if (@user.activation_status == "active") #some code here @user.update_attribute('activation_status' ,'inactive') # Line 44 #send mail to user that his account is…
Salil
  • 46,566
  • 21
  • 122
  • 156
4
votes
1 answer

Nifi PutSQL Timestamp/Datetime error cannot be converted error

I tried the solution suggested to remove the timestamp format conversion error by using "UpdateAttribute" processor i.e. ConvertJSONtoSQL-> UpdateAttribute--> PutSQL In UpdateAttribute I used Property Value --------------- …
Hem
  • 130
  • 2
  • 12
4
votes
3 answers

Rails update_attribute replacement?

Is there a replacement for update_attribute? I know you can still use it in Rails 3 but you get deprecation messages. The reason why I need to use update_attribute is because I need to skip validations but run callbacks. The only way that I've found…
miligraf
  • 1,042
  • 9
  • 22
2
votes
2 answers

Ruby on Rails - set attribute after record was created

I'm using activeadmin in my RoR webapp. when I create a new user/record, I want to set/update an attribute depend on it's id/pk. e.g his id is 1234, column X should have the value 1234-XXX. Since there is no activerecord callback for that(i cant…
2
votes
1 answer

Rails: Why does update_attribute automatically convert types

For example, say I have a User model with an integer column 'pet_id'. If I run user = User.new user.update_attribute(:pet_id, '1') It automatically converts the string '1' to an integer 1. Where does this conversion take place?
Robert
  • 681
  • 1
  • 6
  • 19
2
votes
5 answers

update_attribute/s() is calling callback for save password

I'm trying to update single attribute of a user model from a admin controller (not users controller). While doing this I tried update_attribute() but it was changing the users password also. I think the password is changing because I have…
user1324063
1
vote
0 answers

Thinking Sphinx type integer with has_many association

Example: We have a model Book (title:string desc:text) and a model Reader (some_integer:integer book_id:integer name:string) class Book < ActiveRecord::Base has_many :readers define_index do indexes id indexes title …
1
vote
1 answer

Update Json-Attributes in Apache-Nifi: Jolt

I'm a newbie on Apache Nifi and have the following Problem: I would like to transform a json file as follows: From: { "Property1": "x1", "Property2": "Tag_**2ABC**", "Property3": "x3", "Property4": "x4" } to: { …
MDS
  • 13
  • 3
0
votes
1 answer

Rails 3 update_attribute not firing

I have a member model with a reset_token method (which assigns a user a new token in order to send them an email to reset their password). But update_attribute never saves anything in the database. I have :new_password_token assigned to…
Msencenb
  • 5,675
  • 11
  • 52
  • 84
0
votes
2 answers

Ruby on rails. Update attribute when date passes

I feel this is a very noob question but here goes. I have a model (gig) with a datetime attribute (date), and an expired boolean attribute (expired). I want the expired boolean to set to true when the datetime date passes todays date. In Gig…
Rob Hughes
  • 876
  • 2
  • 13
  • 32
0
votes
1 answer

Rails 4: Update Model Column on Destroy

This is for a ticketing system. When you close a ticket, theres a column of resolution. The user types in the resolution, ie, "this ticket was resolved by xyz". The column is of type textfield, not a string. So you go to close it and type in some…
Nubtacular
  • 1,367
  • 2
  • 18
  • 38
0
votes
1 answer

NoMethodError in PasswordResetsController

Hartl tutorial Chapter 10.2.3 When I attempt to submit existing user email to generate the password reset token, it breaks on the 2nd update_attribute call in the User model: The reset_sent_at column is present in the database, and I can write to…
jjt
  • 125
  • 1
  • 10
1
2