Displaying 20 results from an estimated 300 matches similar to: "Implementing conditional read-only attributes of ActiveRecord objects"
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,
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
2006 Feb 20
1
extract month from date column
Hi,
I have this rails query:
@birthdays = Birthday.find :all,
:conditions => ["user_id = ? and
birthdate = ''2006-02-01'', @user_id],
:limit => @birthday_pages.items_per_page,
:offset => @birthday_pages.current.offset
You can ignore the user_id, limit and offset part.
2006 Jan 06
0
date_select and sessions
i am using date_select to allow someone to select their birthdate in a
form. however date_select uses 3 wierd labels in the forms like
follows:
<select name="user[birthdate(1i)]">
<option value="1940">1940</option>
<option value="1941">1941</option>
.
and then the month is user[birthdate(2i)] and so on. My issue is i
dont know the
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" group.
To post to this group, send email to
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
2006 Jan 07
4
set date with date_select
when retreiving a date from a DATETIME field in a database, is there a
way to set the date to the value of the DB in the view? It seems to
always default to the current date...
if I have a field called birthdate in the users table and i do
@user = User.find(@params[:id])
in my view i have a <%= date_select ''birthdate'',''user'' %>
but dont know how to
2006 Nov 02
0
DB: class to multiple rows mapping (aka rails 'osproperty')
Hi,
Has anyone implemented some sort of automatic class to dynamic table
mapping ?
The idea is to have a single table capable of storing various unrelated
classes. Some sort of Extreme polymorphism.
I''ve used this with other languages. E.g. osproperty in Java. The idea
is the following
In the DB
create table dynamicobjects (
id int,
object_type varchar(255),
key_name
2009 Feb 20
3
mean over previous cells
Dear RUsers,
I guess this is an easy question for someone a little familiar with
programming...(which I am not)...
I've got 2 colummns, one shows just dates(SST_date, Class 'Date' num), the
other one shows the SeaSurfaceTemperature (SST, num) at that certain date.
SST_date SST
2008-01-01 22.2
2008-01-02 21.8
2008-01-03 22.8
2008-01-04 22.9
2008-01-05 23.1
2008-01-06 23.2
...
2006 Dec 15
4
Why won't Rails update my object attributes?
Here''s the issue: When I submit a form for updating,
@person.update_attributes doesn''t work. But the next nested clause for
updating images DOES work. How is that possible? However no matter
what I do the Person object will not change its attributes.
def edit
@person = Person.find(params[:id])
if request.post?
@person.update_attributes(params[:person])
2012 Sep 15
0
Random Forest and Correlated Fields
Does anyone know if there are any special considerations with Random Forest and correlated fields or rather derived fields?
For example if we are trying to predict who might leave our company to go work for another company some of the variables we may look at are below (in addition to others). Do we need to be cautious with comingling these especially since, for example with Age variable, all are
2006 Jan 19
2
date_select broken
I am using date_select and in some instances it only shows about 10
years worth of choices. Same form on other users shows the whole
range. date_select looks like this
<%= date_select ''user'',''birthdate'' , :start_year => 1940 %>
I would expect to always see 1940-2006 or so , but i dont always do.
Is there a way to force the range or explain why i
2008 Jan 12
2
Problems with date field
Hi, I''m creating a date type field to put birthdate, but the years on
this field only go to 2003, what should I do??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To
2006 Jan 04
5
How do I set the default value for date fields?
I want my date fields to default to NIL or "", because the presence of a
date means something. My problem is that rails is defaulting the fields
to today''s date automatically when I create a new record through the
scaffold. I tried removing the default ''0000-00-00'' and changing NOT
NULL to NULL, but both columns get today''s date as the default
2006 Aug 13
0
selected_value or select not work
I''am try using collection_select helper, but the option selected_value
not work
i try like this:
<%= collection_select("user", "gender_id", @genders, "id",
"description", {:include_blank => true, :selected_value => "2"}
[]''s
Bruno
--
Posted via http://www.ruby-forum.com/.
2007 Nov 03
3
Birthdate validation
Hello everyone,
I''m almost cracking my head trying to do this birthdate validation. It
turns out that I can only accept users with at least 18 years old and
I''m trying to validate it writing this code on my user.rb fil at app/
models
class User < ActiveRecord::Base
validates_presence_of :full_name
validates_presence_of :street_address
validates_presence_of :city
2012 Nov 12
2
how to enter a string value
hi,
I want to know just enter a string value
entering a numeric value is make with the function scan () or scan (nmax =
..)
but it does not work for string
my goal is to enter three string: name and surname and date of birth
I try with this code but it shows me errors
print ("enter the name")
name <- scan (nmax = 1)
print ("enter the first name")
firstName <- scan
2009 Jul 02
3
Testing for membership in an array of strings
As an R beginner, I feel brain dead today as I can not find the answer
to a relatively simple question.
Given a array of string values, for example lets say "mary", "bob",
"danny", "sue", and "jane".
I am trying to determine how to perform a logical test to determine if
a variable is an exact match for one of the string values in the array
2006 Feb 22
1
managing dates in forms
Hi,
I have a field for the user which is their birthday. I am letting them
edit it and then save it if they want. However, the form displays the
current date/time, and when they save the form without changing the
birthdate (because they do not wish to set it), the current date/time
gets saved to the db. How do I do this? I thought about having a
hidden field which would be the current date/time
2007 Sep 21
1
calculate age of a person and compare it
how can i calculate the age of a person using database " birth date"
my teble is user and column is bday ....
now i want to calculate the age will some one please tell me how can i
calculate the age..
actually i want to compare my two database fields birthdate and
joining date ......that is why i need this....
will someone please tell me how can i do that