Displaying 20 results from an estimated 4000 matches similar to: "Eager Loading"
2007 Apr 26
1
eager loading not working in production mode
i have an eager load query as such:
@groups = ReviewQuestionGroup.find(:all,
:conditions => ["review_category_id = ?", @review.category.id],
:order => ''review_question_groups.position,
review_questions.position'',
:include => :questions)
in dev mode, this works fine... i get results like
@groups[0].questions.length = 13. in production, i
2006 Jul 14
5
Acts_As_Taggable Plugin multiple controllers.
I have Acts_As_Taggable Plugin working. I have a HR controller and a
sales controller.
I have a document in hr tagged whitepaper and a differnent document in
sales tagged whitepaper
when I am in hr I see the hr document tagged with whitepaper and not
the sale document (what I want). but if I click on the tag whitepaper
I return two documents, hr and sales. I just want to return the hr
document
2007 Oct 18
9
with_scope issue
I have the following code:
class User < ActiveRecord::Base
has_many :requests do
def find_active(options = {})
with_scope :find => { :conditions => ["requests.active = ?",
true] } do
find(:all, options)
end
end
end
end
Executing user.requests.find_active results in the following SQL:
SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND
(
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
2008 Nov 13
5
Touch an ActiveRecord - timestamps
When I update an ActiveRecord, i would like to "touch" one of the
related objects, that the updated record belongs_to, in order to update
the timestamps on the parent record, although i don''t want to change any
of the data in the parent. Whats the accepted way to do this?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You
2006 Nov 01
17
So how can I rewrite my app without using with_scope?
So, I hear that with_scope is going to be deprecated.
Which is a bit of a shame, given the stuff I''ve been writing recently.
I have a CMS with multiple clients. A ''client'' is essentially a
company, with multiple users. Content on the site belongs to a client
- content could be messages, images, schedules, etc etc. People
belonging to one client should not be able
2009 Oct 21
3
alias_method_chain and ActiveSupport::TestCase
I''m trying to add some functionality to the setup method of all my
tests.
I added a method called setup_with_ts in the test_helper and chained
it using alias_method_chain :setup, :ts and that works great for every
test that does not define setup in the test.
So for my unit tests i tried also defining the same method
setup_with_ts in a
class ActiveSupport::TestCase
def setup_with_ts
2006 Feb 07
4
Ruby, Rails & Inheritance
Hi!
I am looking for a solution for the following problem:
Some of my models share some attributes and also was in need for some
extra features, so I created a class "RecordWithFeatures":
-----------------------------------------------------------------
class RecordWithFeatures < ActiveRecord::Base
# @Override
def self.descends_from_active_record?
superclass ==
2006 Mar 03
2
Through relationship
I am working on streamlining one of my apps, and trying to wrap my
hands around through, polymorphic, and with_scope. All of these i
know i need for what i want to do, based on the little documentation
I have found. With this in mid I have tried to implement a simple
through in the app to try and get my head around it. This is what I
have:
class Product < ActiveRecord::Base
2010 Aug 10
3
ActiveRecord::UnknownAttributeError: unknown attribute: <script type
Has anyone seen this happening to their apps?
I''m starting to get errors like this come across from one of my apps:
ActiveRecord::UnknownAttributeError: unknown attribute: <script type
The parameters being sent are:
{"user"=>
{"email_confirmation"=>"someone-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org",
2006 May 03
3
My Tooltips contribution
All --
I've been working on a simple tooltip widget and thought I'd release
it into the wild. It builds on the features found in Prototype 1.5.0
RC0 and Scriptaculous 1.6.1.
Very basically, it walks down a list of links and if they have id,
href and title attributes, displays a tooltip on mouseover. Styled
with a few lines of CSS and background images.
You can demo it here:
2006 Apr 01
1
STI with_scope on parent - bug or feature?
Hi,
It seems that setting a with_scope on the parent class doesn''t do anything
MyClass.with_scope(:find=>{:conditions=> ["somecol = ?", ''val'']}) do
@ext_pages, @ext_rows = paginate :my_extended_class, {
:per_page => 13
}
end
# this doesn''t generate WHERE somecol=''val''
In order for scope to work you have to call
2007 Mar 13
5
Question on application/database design for a application port to rails
Hi all
I am hoping that the experience and knowledge of this ''list'' will be
able to help me out with some design decisions I have to make while
porting a desktop app to rails.
Here is the scoop:
I am in the design process of porting a fairly large client/server app
to rails. Average data set is about 200 MB per database/server.
Altogether there are about 100 tables and about
2007 Oct 04
3
Is stubbing a call to super possible?
Hi
Is stubbing a call to super possible? I am testing a protected
method called authorized in a Rails controller ... part of the logic
flow calls super which calls the method authorized in the application
controller.
As I am focused on the logic of the method in the controller I am
testing I just wish to stub the value returned in the super.
Is this at all possible?
Cheers
Shane
2006 Sep 08
1
has_many relationship extensions and scoping rules
Hi all !
Is this supposed to work ?
class Email < ActiveRecord::Base
has_many :to, :class_name => 'Recipient', :conditions =>
"recipients.source = 'to'" do
def create!(*args)
with_scope(:create => {:source => 'to'}) do
super
end
end
def build(*args)
with_scope(:create => {:source => 'to'}) do
2006 Nov 21
2
Accessing scopes
If with_scope has been called previously, how do I access the find
conditions dynamically?
I am asking because I am using a find_by_sql call (which clobbers the
with_scope). How can I access the method scoping so that I can read it
and incorporate it into my query manually?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
2006 Apr 20
3
has_many :through with has_many/has_many join models
It seems that using a join model that joins with two has_many''s will
fail to generate proper SQL
class StudentSemesterRecord < ActiveRecord::Base
belongs_to :semester
has_many :discipline_records, :through => :semester
end
class Semester < ActiveRecord::Base
has_many :student_semester_records
has_many :discipline_records
end
class DisciplineRecord <
2009 Jan 21
3
Nested serialization with to_json and to_xml with array and hash element
Title: Nested serialization with to_json and to_xml with array and
hash element
class Person < ActiveRecord::Base
has_one :address
has_one :job
def office()
return "Executive_Suite"
end
end
class Address < ActiveRecord::Base
belongs_to :person
end
class Job < ActiveRecord::Base
belongs_to :person
has_one :paygrade
def Title
return "Engineer"
end
end
2009 Nov 10
10
Un-recognised routes that do exist, using namespaces & subdomain checking
I''m getting really cheesed off with RSpec not matching some of my
routes when controller testing when I have subdomain checking
(courtesy of subdomain-fu) on namespaces. These routes appear in the
rake routes output, and work fine via HTTP requests .
The really annoying thing is it''s working fine for routes that aren''t
at the root of the namespace.
E.g. say I have
2009 Nov 17
5
has_many :through and foo.bars.include?
hallo everybody,
i already googled the following problem, but there are so many
questions regarding "has_many :through", that i just couldn''t find
what i was looking for. so, i''m really sorry if this has been asked
before. if so, just drop me the link.
i have a has_many :through relationship similar to the following
example:
class Group < ActiveRecord::Base