Displaying 20 results from an estimated 100 matches similar to: "checkboxes with a has_many :through relation"
2006 Jul 10
10
has_many :through and foreign key parameters
I just took my HABTM and turned it into a :through since my join table
has another "non-joiny" attribute.
I went from this:
has_many_and_belongs_to :jobs, :join_table => ''tablename'',
:foreign_key => ''x'',
:association_foreign_key => ''y''
to this:
has_many :jobs, :through =>
2006 Jul 12
0
Give form elements "fieldWithErrors" class in non-std. way?
All,
I want to know how to force an element of my model to be invalid, but
not generate any message for it, so that the corresponding form field on
a form will show up with the ''fieldWithErrors'' class.
I have some checkboxes on my RHTML form, and they are generated with
this code
<%= check_box_tag("current_job[target_list_ids][]"...etc. %>
target_list_ids
2006 Jun 27
3
belongs_to <parent name>, :foreign_key modifier not working
All,
I have two ActiveRecord objects.
TargetList has_many Targets
Targets belongs_to TargetList
I''ve specified
belongs_to :target_list,
:foreign_key => ''DataSetID''
Queries generated by various methods in target_list do not seem to see
the
foreign_key name and keep trying to query my Target table using
"target_list_id" (the default foreign
2006 Jul 18
2
validate method doesn''t recognize another instance method
All,
I am attempting to do some custom validation on my object.
Here is my validate method:
protected
def validate
puts "Do I have the target_list_ids method? " +
self.methods.include?(''target_list_ids'').to_s
if target_list_ids.nil? || target_list_ids.length == 0
errors.add_to_base("You must choose at least one target list for
this job")
2006 Jul 12
1
validate method not getting called?
Here''s a snippet of my model:
validates_presence_of :from_name, :from_email, :reply_name,
:reply_email, :eSubject
protected
def validate
puts "Calling: #{target_list_ids}"
errors.add_to_base("You must choose at least one target list for
this job") if self.target_list_ids.nil?
end
It appears that the validates_presence_of are being called just fine,
2006 Mar 18
9
Using <%= text_field %> within partials is problematic
All,
Thanks for any help in advance.
I have what I think is a very straightforward partial template and I
can''t figure out why a text_field call within it doesn''t work.
Here is my calling template: lists.rhtml
<div id="target_lists">
<%= render(:partial => "target_lists", :collection => @target_lists)
%>
</div>
In the partial
2006 Dec 29
4
Strange HABTM behavior against SQL Server (AR 1.14.4)
All,
Win XP
SQL Server 2000
Rails 1.1.6 (AR 1.14.4)
I have two objects (Job and Warning) in a HABTM relationship. Below are
the pertinent sections of the model files and the schema for the join
table.
job.rb:
class Job < ActiveRecord::Base
has_and_belongs_to_many :warnings, :foreign_key =>
''JobReferenceNumber''
set_table_name :JobData
set_primary_key
2006 Jul 06
3
Understanding date_select naming conventions
I am using the date_select helper to generate date select elements in a
form.
I notice that the generated HTML shows that these selects have the
following names:
Month: current_job[StartDate(2i)]
Day: current_job[StartDate(3i)]
Year: current_job[StartDate(1i)]
I''m assuming that the Xi identifiers somehow specify the appropriate
date part from a date or time value.
Can anyone
2006 Jul 06
4
ERb question: Embedding <%= %> in helper method calls
I had a situation where I wanted to use a <%= %> (scriptlet) in my
text_field call to set the "disabled" attribute on the text field, like
so:
<%= text_field(:current_job, ''removeLinkPos'', :value => '''', :id =>
''offset'', :maxlength => 2, :disabled => <%= sometest ? ''true'' :
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All,
I''m having a hell of a time figuring out what is going on here.
I''m trying to override one of my getters so that I can format it a
certain way in my form. But I can''t seem to get text_field to call the
appropriate method on my object.
So here''s my getter:
public
def FAX
fax = read_attribute(:FAX)
puts fax
2006 Jul 17
18
Inserting datetime value into SQL Server
I have a SQL Server column named StartTime of (SQL Server) type datetime
If I attempt to set the attribute using
public
def StartTime=(time)
write_attribute(:StartTime, "{ts ''1899-12-30
#{time.hour}:#{time.min}:#{time.sec}''}")
end
it''s inserting a NULL value.
Anyone else able to successfully insert a date time value into a SQL
Server table using
2006 May 25
5
rake migrate VERSION=0 doesn''t appear to execute
All,
I''ve decided to jump into Migrations before I get too far along on the
DB side of things.
I already have some tables built, and I went ahead and built the
migration that would have created them from scratch, and I made sure
that there was a self.down section to drop them. I wanted to verify
that I could roll back so I figured I would use rake to drop these
pre-existing tables
2006 Mar 20
5
Wrap error_messages_for() call when no instance var present
I am trying to put some smarts around a call to
<%= error_messages_for %>
so that when I first come into this page i.e. when my instance variable
@target_list has not been defined yet, the page doesn''t break.
I''m doing this:
<% if @target_list? %>
<%= error_messages_for ''target_list'' %>
<% end %>
I get a syntax error on line 1.
2011 Aug 17
1
Why does the graph converge?
I have a set of functions:
Probability <- function(N, f, w, b, l, n, q) {
#N is the number of lymph nodes
#f is the fraction of Dendritic cells (in the correct node) that have the
antigen
#w is time in terms of hours
#b is the starting position (somewhere in the node or somewhere in the gap
between nodes. It is a number between 1 and (x+t))
#q is the length of the time step
#l is the LN
2006 Jul 18
1
Auto-populating time portion of a datetime field from a form
I see that if I use the date_select helper in my view, then in the
generated page, my selects are named obj[datetime_field(1i)] (and 2i and
3i for the other parts). These auto-populate the date portion of my
datetime_field.
I have another datetime field that I''m presenting the time from and I
would like to use a similar scheme to autopopulate it. Currently, I''ve
used the
2006 Mar 14
4
What does the send() method do on a model object?
All,
I did a scaffold for a model and I ended up with this code in
list.rhtml:
<% for column in TargetList.content_columns %>
<td><%=h target_list.send(column.name) %></td>
<% end %>
Where is the "send" method and what does it do?
I can''t find it on ActiveRecord::Base? I assume that it returns a
value based on the column id but I
2006 Jul 03
4
text_field doesn''t call overridden ActiveRecord getters
All,
In a template, I have
<%= text_field :target_list, :DateReceived,
{ :title => ''uploaded_at'',
:class =>
''target_list_info'',
:disabled => ''true'' } %>
Here is the DateReceived method on my
2008 Feb 05
2
How to generate table output of t-test
Hi,
Given
test <- matrix(c(1, 1,2,2), 2,2)
t <- apply(test, 1, t.test)
How can I obtain a table of p-values, confidence interval etc, instead of
[[1]]
One Sample t-test
data: newX[, i]
t = 3, df = 1, p-value = 0.2048
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-4.853102 7.853102
sample estimates:
mean of x
1.5
[[2]]
2008 Mar 19
5
object_transactions plugin w/2.x disables AR session store
All,
Win XP
Rails 2.0.2
object_transactions plugin
(http://code.bitsweat.net/svn/object_transactions/)
transaction-simple gem 1.4 (required by object_transactions plugin)
AR SQL Server Adapter 1.0
SQL Server 2000
Using the object_transactions plugin with Rails 2.0.2 (and I assume
based on what I''m seeing that this goes for Rails 2.x) disables the
ability to save to an ActiveRecord based
2004 May 18
1
list & calculaton in many df subsets
Hi,
have anybody a hint /starting point how i can
enlarge my code that's posiible for me make any calculaton's
with variables in the 64 subset's.
Example:
I want calculate difference of two variables inside every
of the 64 subset data.frames and getting this value in tList!
Many thanks,
Christian
tasign <- paste("tList[[n]] <- try(dtree[dtree$class02 ==