Displaying 20 results from an estimated 1100 matches similar to: "Display find(:include => [:children]) results in a view"
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come
in. Console just gives me back :account_id => nil. Obviously I''m trying to
set it though. Silly console...
But, I can set the account_id column in my controller like so:
@user = User.new(params[:user])
@user.account_id = account.id
@user.save
Here''s what I give to the controller:
User.create :name
2006 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
I just switched from using the standard "id" column into using my own
primary key and generating my own unique id for each record. But, this
breaks acts_as_tree.
Because my new primary key is not an integer, it breaks the SQL query
as follows:
StatementInvalid in PagesController#create
--------------------------------------------------------------------------------------
2006 Jan 11
3
How do you do a custom sql call in rails?
Hi.
I am developing an industry specific crm that allows busineses to track
customers in a particular way. Each customer will be assigned a customer
number. The first customer will have a customer number of 1, the second
customer_number = 2, etc... Note that this customer number is not global
but particular to the account that created the customer (see schema snip
below).
I need to have a
2008 Nov 12
5
dynamic condition for has_one and eager loading issue
Hi,
I ve defined the following relation in one of my models with a dynamic
where condition:
has_one :selection,
:foreign_key => ''object_id'',
:conditions => ''selection_type = 1 and account_id = #
{self.send(:account_id)}''
That works perfect, however when I try to eager load that relation I
am getting the following error when doing a
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is
something borked?
>> c=Contact.last
=> #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone:
2147483647, account_id: 8, created_at: "2009-11-27 18:16:25",
updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone:
false,
2010 Dec 02
8
CanCan issue when being very specific
So I got CanCan and Devise working well. I have two types of users:
Admins and Nonadmins. Admins can edit all of Nonadmins profiles.
The problem is, every user (either Admin or Nonadmin) belongs to an
Account or Organization. Admins should only be able to edit users from
their own Account or Organization. I was able to do that too.
The problem is, I can''t display the Create New User
2006 Jan 19
4
A simple scaffolding question
All,
When I generate scaffolding on my model, it doesn''t display all the
fields in the create and edit views. It populates the views with
text/char and date types, but omits any integer fields. Is this
normal behavior or a bug?
Thanks!
-Nick
2006 Jan 17
9
using "find" when you have 2 has_many relations
An Account has_many Websites which in turn has_many WebsiteDomains
Now I can of course do this:
@domains = Account.find(1).websites.find(1).website_domains.find(:all)
To get all the domains for Account with id 1 and Website with id 1.
I would like to do something like this though:
@domains =
Account.find(1).websites.find(:all).website_domains.find(:all)
IE, get ALL domains for all websites in
2008 Jul 16
2
belongs_to causing endless loop on first call to save!
Hi,
I have a situation I''m hoping someone out there may be able to shed some
light on. I have a Rails app (2.1.0 on Ruby 1.8.7) with a wizard-based sign
up process, that has recently been changed from storing incremental data in
the database to having a medium sized object graph living in the user
session until the user completes the entire sign up process (this is a
business
2006 Jul 19
2
Creating a safe sequence generator
Hi all,
I''ve got a rails and database question. Accounts have jobs, and job
numbers should be assigned per account. Account 89 should have jobs
1-whatever, which are not the same as account 67, which has jobs
1-whatever.
In the past, I have accomplished this quite easily with:
create table job (
accountid int(10) unsigned not null default 0,
jobid int(10) unsigned not null
2005 Oct 03
2
Explanation of how Scope works?
Hello all,
I was wondering if someone could give me a brief explanation of
how :scope works. I believe I''ve seen it used with the validation
helpers in the past.
- Jim
2009 Jan 28
3
Newbie question about "grouping"
Hi folks:
I am a SQL guy who just downloaded and installed R yesterday. I am
trying to evaluate some "complex" aggregations we are currently
performing with Syncsort (and have tried in Oracle) with R. I have
loaded data in a dataframe and have performed some of the simple
aggregations on a subset of data. What I do not see how to do though,
is to "group" the aggregations
2006 May 07
4
Paginate() from multiple tables
Hi
I''m wondering if there''s a way I can gather data from multiple tables
from the child table by using the paginate method?
I would have done it using select_by_sql but I need it to paginate.
My table structure is:
Records is a child of Date and Account
Date Account
| |
^ ^
Records
I want to be able to print a table using the Records controller that
will
2007 Dec 04
1
spec''ing shared controller methods
I want to isolate and spec methods that are shared by controllers,
and live in application.rb.
Whereas I usually also provide examples in individual controllers
that use these methods, not necessarily all the edge cases and I''d
like to isolate the examples.
This is the approach I''m taking (thanks to bryanl for suggestions and
http://pastie.caboo.se/123626). WDYT?
This
2006 Jun 24
5
Rake vs Ruby for running tests (error discrepency)
I''m having (to me) a strange problem with errors when running my tests
with rake as opposed to using ruby. If I do rake test:units I get this
error for several tests, but not all:
13) Error:
test_player_has_game_statistics_for_season(PlayerSeasonTest):
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry ''22'' for
key 1: INSERT INTO positions (`name`, `id`,
2006 Nov 26
5
associations help?
I have Users who can "own" Projects. There is only one owner. Users in
general can be authorized to view certain projects. Here is my initial stab
at this:
class User < ActiveRecord::Base
has_many :projects # ownership
has_many :project_viewers, :dependent => :destroy
has_many :projects, :through => :project_viewers, :uniq => true
...
end
class
2007 Dec 02
1
total_hits and conditions
Hi. I''m running 0.11.4. The problem I''m having, appears to have been solved
before according to various posts I googled up, but possibly the fix got removed
from 0.11.3 to 0.11.4?
re = Entry.multi_search(''service'', [Ticket], options, {})
re.size
620
re.total_hits
620
Now add conditions:
re = Entry.multi_search(''service'', [Ticket],
2009 Aug 04
1
Output XML to File
I am trying to read some information based on a user id, then search the
database for the needed info and build an XML file. Everything seems to
be working fine; I read the info, I create the xml and even spit "stuff"
out to file. The issue is that the "stuff" I am writing to a file is a
xml/html cross cluster #@%$ of stuff. Here is some code:
if !params[:id].blank?
2012 Sep 02
1
to_model
There''s a number of calls in the Rails source to convert_to_model,
which takes an activerecord object instance:
convert_to_model(object)
Here''s the thing. All convert_to_model does is calls to_model, which
returns self (the ActiveModel instance).
Am I missing something here? Why call a method that returns the same
thing?
@user
=> #<User id: 3, name:
2006 Jan 05
3
has_one :dependent => true question
Hello,
I have two classes that are self explanatory and are listed below.
class User < ActiveRecord::Base
belongs_to :account
end
class Account < ActiveRecord::Base
has_one :account_owner, { :dependent => true, :class_name => "User",
:conditions => "is_account_owner = 1" }
has_many :users
end
In the signup controller when an account is created one user