Displaying 20 results from an estimated 32 matches for "has_many_associations".
Did you mean:
has_many_association
2007 Nov 29
4
collection.build or collection.create gives "ArgumentError: wrong number of arguments (1 for 0)"
I have a Project that has_many Tasks. Tasks belongs to a Project. When
I try the following:
project = Project.new
project.tasks.build
I get:
>> s = Project.new
=> #<Project:0x25f9e28 @attributes={"name"=>"", "end_at"=>nil,
"updated_at"=>nil, "published_at"=>nil, "user_id"=>nil,
2007 Jul 19
7
NoMethodError in partial driving me mad
Hello,
i simplified have a news model, a news category model and a news
controller.
my _news.rhtml partial renders a single news entry.
in my controller there are the actions show and show_category.
if the "show" action is called, a single news item is rendered through
my partial with no errors.
if the "show_category" action is called, i get a NoMethodError while
displaying
2009 Jun 04
1
wrong number of arguments (1 for 0)
...9;ve used console to test my models and they all work
ok, I can do manually what I''m trying to do with Rails. There is
something in the code somewhere outside of the model code that is
causing this problem and I''m at a loss to track it down.
I''ve traced into the code for has_many_associations.rb:
def insert_record(record, force = false, validate = true)
set_belongs_to_association_for(record)
force ? record.save! : record.save(validate)
end
and it blows up on the force ? record.save! : record.save(validate)
line. Here is the stack trace:
wrong numbe...
2006 Feb 23
3
has_many reference
I am trying to do something right from Agile Web Dev with Rails book
and it does not work. I must be missing something obvious.
I have a one-to-many relationship:
class Draft < ActiveRecord::Base
has_many :endorsees
end
class Endorsees < ActiveRecord:: Base
belongs_to :draft
end
>From my reading, methinks I should be able to say:
d = Draft.new
d.endorsees << Endorsee.new
2009 Sep 09
0
Rails 2.3.4 ActiveRecord association problem
...`add_record_to_target_with_callbacks''
My code (in snippets):
class Trip < ActiveRecord::Base
has_many :activity_reservations
end
class ActivityReservation < ActiveRecord::Base
belongs_to :trip
end
trip.activity_reservations << ActivityReservation.new
The has_many_associations code referenced:
def insert_record(record, force = false, validate = true)
set_belongs_to_association_for(record)
force ? record.save! : record.save(validate)
end
The ActiveRecord save method:
def save
create_or_update
end
The comments for...
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application.
The form collects account info, company info, and then info for an
administrative user.
The method looks like this:
def create
@account = Account.create!(params[:account])
@company = @account.companies.create!(params[:company])
@user = @company.users.create!(params[:user])
end
However, this inevitably fails
2007 Jun 01
0
"Exception: stack level too deep" on collection.clear?
Without getting too deep into my app I''m wondering if anyone has any
clues what might give rise to the error posted below. It occurs when
I run my unit tests.
class Actor < AR:Base
belongs_to :court_case
end
class CaseCause < AR:Base
belongs_to :court_case
end
class CourtCase < AR:Base
has_many :actors
has_many :case_causes
...
end
def my_test_method
...
2008 Mar 07
3
Boolean circles..
Hi,
This is just kindof a RoR question, but since you all potentially do
the same things as I do, I thought I''ll ask here..
Im trying to use the boolean type in the database. Migrations is no
problem, it even converts the 0/1 values from my import CSV to false
and true.
However, I cannot make the :conditions part of a find work:
Loading development environment (Rails 2.0.2)
>> c
2006 Dec 22
2
Relating Namespaced Models
I am dealing with a large project. I use a lot of STI and therfore have
a lot of models. I''d like to use namespaces to help organize my models
but am having trouble getting started.
I have a base model Term::Base located in /app/models/term/base.rb:
class Term::Base < ActiveRecord::Base
set_table_name "terms"
end
I have a non-namespaced client model:
class Client <
2006 Feb 25
5
MySQL client ran out of memory
I''m getting the following error unexpectedly for my rails app. I just
exported the databae from dreamhost and imported it on textdrive for
my rails app.
Mysql::Error: MySQL client ran out of memory: SELECT COUNT(*) FROM
comments WHERE (comments.listing_id = 2666)
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract_adapter.rb:88:in
2006 Feb 10
1
Auto-generated find queries adding bogus WHERE clauses
[Sorry for the poor subject; this is really hard to explain]
I''m trying to run a search over several objects which themselves contain
multiple model objects, like so:
class Collection << ActiveRecord::Base
def findpkg
self.repositories.each do |r|
p = r.packages.find(:all, :conditions => "name like ''%pkg%''")
end
end
end
2007 May 24
3
Annoying problem, stack error
For some reason rake spec is totally crapping out on me.
I don''t know what I did to make it break, the only thing I tried new
was install haml, but even after removing it there is still a stack
trace.
Here is what I am getting-
sparta at phalanx ff $ rake spec
(in /Users/sparta/Projects/work/idastudios/ff)
2006 Aug 08
1
File upload into Mysql (using lighttpd) problem
Hello All,
I''ve run into a snag. (I apologize in advance. I''m not very good at
system administration.)
I''m building an app that allows users to upload files. Up until now I
have been storing the files on the file system, but tonight I decided to
change the app so the files are stored in the database as a longblob.
I thought everything was working great, until I
2006 Apr 20
1
has_many.count not accepting options hash
has_many.count does not seem to support an options hash like
ActiveRecord::Base.count does.
Example:
>> AcademicProgram.find(:first).course_requirements.count :conditions
=> "courses.name LIKE ''a%''", :include => :course
=> 40
>> ap.ap_requirements.count :conditions => "courses.name LIKE ''a%''",
:include =>
2006 Apr 16
8
"Cannot convert String to Integer" after using association
So, I''ve written a partial that does some stuff with a given instance of
my class "entity". Entity is ActiveRecord. I''m able to retrieve all
sorts of data from an @entity, until I do something like:
<% for @attribute in @entity.attributes %>
<div id="attribute_<%= @attribute.id %>">
<%= render(:partial =>
2007 Feb 08
5
a possible bug in Has_many :through using :soucre
I''ve been stumped on this for a few days and I''m not sure if it''s an error
on my end or an actual bug.
I have a system where I have workshops and users. Workshops have students,
presenters, and troubleshooters. I wanted to represent this simply by
using has_many :through with :source.
Workshop
has_many :presenters, :through =>:presenterships, :source=>:user
2007 May 30
2
ActionView::TemplateError
Hi,
I have a strange problem that only occurs on the production server.
I''ve been banging my head for hours trying to figure it out with no
success. Below is a copy of the error from the production log.
ActionView::TemplateError (Expected /www/rails_apps/scanlan/current/
public/../config/../app/models/image.rb to define Image) on line #6 of
app/views/admin/design/_record.rhtml:
3:
2006 Jan 19
7
bug in has_many count?
I can submit a patch, but wanted to confirm I''m looking at this right...
The docs indicate that if you specify a has_many association with
:finder_sql, but no :counter_sql, it constructs the appropriate counter
sql by substituting the SELECT clause.
But has_many_association.rb doesn''t seem to do that -- it just passes
Base#count_by_sql the finder_sql, which doesn''t
2007 Oct 08
1
Rails reverses apostrophes
Hi,
I am quite new to Ruby on Rails so this might have a very simple
answer... My problem gives the following error message when I try to
call the count function for an item.
Mysql::Error: Unknown column ''TournamentTemplate'' in ''where clause'':
SELECT count(*) AS count_all FROM action_logs WHERE
(action_logs.loggable_id = 1 AND action_logs.loggable_type =
2007 Jan 05
6
RSpec 0.7.5 with Rails and rcov
I seem to be missing something because I am at a loss on how to get
rcov, RSpec, and Rails working together. Would someone mind dropping
some hints?