update-attributes Questions
5
Solved
To check if buyer.save is going to fail I use buyer.valid?:
def create
@buyer = Buyer.new(params[:buyer])
if @buyer.valid?
my_update_database_method
@buyer.save
else
...
end
end
How could...
Owens asked 17/1, 2011 at 13:12
6
I cant figure out how to update/rename a file uploaded/managed with Carrierwave-mongoid in rails 3.2.6. I want to rename the file in the db as well as on the filesystem.
Something like this maybe....
Cata asked 18/10, 2012 at 21:44
5
Solved
I have a before_save in my Message model defined like this:
class Message < ActiveRecord::Base
before_save lambda { foo(publisher); bar }
end
When I do:
my_message.update_attributes(:cre...
Lucifer asked 30/8, 2011 at 13:15
9
Solved
Right now, users can edit some their attributes without having to enter their password because my validations are set up like this:
validates :password, :presence =>true, :confirmation => t...
Illyricum asked 16/8, 2011 at 19:2
4
Solved
I have a user and nested profile class as follows:
class User < ActiveRecord::Base
has_one :profile
attr_accessible :profile_attributes
accepts_nested_attributes_for :profile
end
class Prof...
Nutty asked 30/3, 2012 at 13:36
2
Solved
hoping someone here can point me in the right direction.
I have a controller Update def running "update_attributes". Currently it returns false, with no error message. I'm fairly new to Ruby, but...
Sorbose asked 17/4, 2012 at 10:4
11
Solved
obj.update_attribute(:only_one_field, 'Some Value')
obj.update_attributes(field1: 'value', field2: 'value2', field3: 'value3')
Both of these will update an object without having to explicitly tell...
Acceptance asked 6/5, 2010 at 4:49
6
Solved
This is probably one of the things that all new users find out about Rails sooner or later. I just realized that rails is updating all fields with the serialize keyword, without checking if anythin...
Bradberry asked 5/1, 2012 at 15:39
1
How can I specify validation_context with update_attributes ?
I can do that using 2 operations (without update_attributes):
my_model.attributes = { :name => '123', :description => '345' }
m...
Hydracid asked 6/12, 2011 at 9:7
1
I have model Company and company has mounted carrierwave uploader Logo.
class Company < ActiveRecord::Base
mount_uploader :logo, LogoUploader
Images upload works, but I have an issue with up...
Phillipphillipe asked 30/3, 2014 at 18:59
2
Solved
My problem is I've run into limitations of accepts_nested_attributes_for, so I need to figure out how to replicate that functionality on my own in order to have more flexibility. (See below for exa...
Mascle asked 26/3, 2013 at 22:13
1
Solved
I have a three models Report,Question,Answer
Answer
belong_to :question
Question
belong_to :reports
has_many :answers, :dependent => :destroy
accepts_nested_attributes_for :answers, :allow...
Skyline asked 4/12, 2012 at 9:6
3
Solved
I've got the following Model:
class GuestCatering < ActiveRecord::Base
# Validation
validates :name, :presence => true
validates :order_number, :presence => true
validates :orderable...
Nucleoside asked 7/3, 2011 at 11:32
2
Solved
def update
@album = Album.find(params[:id])
if @album.update_attributes(params[:album])
redirect_to(:action=>'list')
else
render(:action=>'edit')
end
end
A Rails 1.1.6 tutorial that ...
Hunyadi asked 8/5, 2009 at 14:55
1
Solved
I'd like to know which fields have been updated after an update_attributes statement. I'm filtering the updatable parameters and deleting those that I don't want updated from the params[:model]. No...
Scribner asked 18/6, 2012 at 11:22
1
Solved
Ive got the following problem. I have a model called user which has a column named activated. Im trying to update that value whith the method activated?, but it gives me the error: Validation faile...
Strife asked 26/3, 2012 at 21:6
1
Solved
I have in a form (form_tag) several checkboxes like this:
<%=check_box_tag 'model_name[column_name]', 1, (@data.model_name.column_name == 1 ? true : false)%>
And updating them like:
varia...
Leff asked 22/2, 2012 at 23:59
2
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 ...
Kajdan asked 26/8, 2010 at 10:30
1
Solved
So I've got a user model, with login, email address, password, password confirmation, name, avatar (picture), etc. There are validations on the first 5, basically stating that all 5 need to exist i...
Barter asked 17/7, 2010 at 15:46
1
© 2022 - 2024 — McMap. All rights reserved.