similar to: Rails3: ActiveRecord includes(:) not working

Displaying 20 results from an estimated 50000 matches similar to: "Rails3: ActiveRecord includes(:) not working"

2010 Nov 11
5
ActiveRecord query
I have these sql code in postgresql "SELECT * from convenios where id NOT IN (SELECT convenio_id from solicituds where usuario_id=?" but don''t find a way of used it in rails except find_by_sql. There is a another way?? class Usuario < ActiveRecord::Base belongs_to :persona has_many :solicituds, :dependent => :destroy has_many :convenios, :through =>
2010 Jan 27
2
has_many, through with nested models?
First the data model: class Forum < ActiveRecord::Base has_many :topics, :dependent => :destroy, :order => ''created_at desc'' end class User < ActiveRecord::Base has_many :topics, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :replies, :dependent => :destroy end class Topic < ActiveRecord::Base belongs_to
2011 Jul 26
1
ActiveRecord has_many associations
Given the models Country, State, City and Person as follows. class Country < ActiveRecord::Base has_many :states end class State < ActiveRecord::Base belongs_to :country has_many :cities end class City < ActiveRecord::Base belongs_to :state has_many :people end class Person < ActiveRecord::Base belongs_to :city end Is there any way that doesn''t allow to delete
2010 Aug 26
0
Eager loading a has_many :through (Rails3)
Hello all, I''ve been trying out Rails 3 and can''t get past this issue: I have a simple has_many :through: class Author < ActiveRecord::Base has_many :author_series has_many :series, :through => :author_series end class Series < ActiveRecord::Base has_many :author_series has_many :authors, :through => :author_series end In my controller I would like to
2011 May 31
1
Geokit query with multiple models involved
Hello, My database structure consists of Store, Book, BookStore and Address as below. class Store < ActiveRecord::Base has_many :book_stores has_many :books, :through => :book_stores has_many :addresses acts_as_mappable :through => :addresses end class Address < ActiveRecord::Base belongs_to :store acts_as_mappable end class Book < ActiveRecord::Base has_many
2011 Dec 07
2
Question About Separation Of Concerns (ActiveRecord)
Hello, I''m a bit stuck with where to put some method calls (separation of responsibility) and although I''m trying to do it just simply now in the models, I think my problem raises a bigger question about Fat Models. But that''s another subject for another day. Right now, I have .... Event has_many meetings ## has an a invitation_expiry date field. def
2010 Mar 10
0
Rails ActiveRecord associations autosave option
I have the following associations. class Document < ActiveRecord::Base has_many :document_sections, :dependent => :destroy, :autosave => true has_many :document_items, :through => :document_sections end class DocumentSection < ActiveRecord::Base belongs_to :document has_many :document_items, :dependent => :destroy, :autosave => true end class DocumentItem <
2012 Feb 04
0
ActiveRecord Associations not working in RSpec with Devise
Hi everyone, I have the following classes: class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :timeoutable, :recoverable, :rememberable, :trackable, :validatable has_many :comments, :dependent => destroy ... end class Comment < ActiveRecord::Base belongs_to :user belongs_to :commentable, :polymorphic => true ... end In rails console,
2010 Feb 11
3
Parameterized ActiveRecord Associations: Any such thing?
Hi list, how are ya? So, my current project is just begging for the ability to have parameterized associations in my ActiveRecord classes. Basically I need something that is a cross between named scopes and standard associations (has_many specifically). I''m wondering if such a thing exists or, if not, if anyone else has an elegant, equivalent solution? Example: class Sprocket <
2013 Jul 21
4
how to use activemodel collection.build for a has_many :through association
Hi all, In my controller I am doing the following to populate a nested form for a has_many through association: def new @specification = Specification.new Component.find_each.each do |component| @specification.component_specifications.build(:component_id => component.id) end The idea being whenever someone creates or edits a form, it will be populated with all
2008 May 21
2
Replacing ActiveRecordStore::Session with a custom model
Has anyone managed to replace ActiveRecordStore::Session with their own model? In the source (http://dev.rubyonrails.org/browser/trunk/actionpack/lib/ action_controller/session/active_record_store.rb) it says you can override the default by setting CGI::Session::ActiveRecordStore.session_class = MySessionClass I have tried doing this in a number of ways but I get all kinds of weird errors, as
2010 Nov 18
7
Rails 3 ActiveRecord queries - I'm missing something very BIG
Hi, I know I am missing something very big regarding the changes with respect to activerecord in Rails 3. I can''t find the explanation. And I''m sure someone will kick my ass for not finding the right piece of info in the docs and guides. Please do. I have a working piece of code but I don''t like it. So. Very basic association: class Project < ActiveRecord::Base
2011 Jul 25
1
3 models in a form.
Hello, class Customer < ActiveRecord::Base has_many :deliveries class Delivery < ActiveRecord::Base has_many :delivery_items has_many :products, :through => :delivery_items belongs_to :customer class DeliveryItem < ActiveRecord::Base belongs_to :delivery belongs_to :product I create a new delivery for customer x: = simple_form_for @customer do |f| = f.simple_fields_for
2009 Jul 31
8
Would like include model association in to_xml
i have: class Library << ActiveRecord::Base has_many :books end class Book << ActiveRecord::Base belongs_to :library end in my controller i have: render :xml=> Library.find(:all).to_xml(:include=>books) but, i would like put a condition in the books ( e.: pages >= 100 ) i would like to create a xml with all Libraries, but books with pages more than 100) How to
2011 Nov 12
3
complex form with dynamic fields.
I''ve seen http://railscasts.com/episodes/73-complex-forms-part-1, part2 and part3. It seems to be my case. I have: Company has_many :documents has_many :tenders, :through.......... and Document belongs_to :company Tender has_many :companies, :through.......... I want to insert documents and tenerds on company creation. If documents are more than one the user can click "add
2010 Jan 25
0
has_many, :finder_sql, setting attributes
Hi all, My question is somewhat complicated, but bear with me. My project has a number of models: User, Program, and Team. Users belong to multiple Programs. Programs have multiple teams, but Teams belong to one program. For each Program a User belongs to, he can belong to multiple Teams. (Think of this in an athletic context where users are athletes, programs are universities). So my
2010 Jun 29
3
belongs_to. Association methods don't pass data to DB
Hi. I have a problem with the association methods which passed to a model through a belongs_to declaration. Here''s an illustration of the issue: GIVEN: # migration class CreateArticlesAndAuthorsTables < ActiveRecord::Migration   def self.up     create_table :articles do |t|       t.text     :title       t.integer :author_id     end     create_table :authors do |t|       t.text
2011 Nov 24
5
ActiveRecord::AssociationTypeMismatch
Hi to all, I have this error and I don''t understand why. I have three model, Image and Playlist and PlaylistItem. Everything works fine. The app should work also a XML REST service. When I made this call I obtain this XML because the playlist don''t contains images: GET http://0.0.0.0:3000/playlists/7.xml <playlist> <id>7</id>
2013 May 13
1
RAILS GET IDS
I don''t know how to solve something about a project I''m doing in Ruby on Rails. I want to save the IDS of my 3 models to my table DETAILS between these, my BD is Mysql. ASIGNATURAS--MALLAS--NIVELS-------->ASIGNATURA_ID--_MALLAS_ID--_NIVELS_ID In the view MALLA, i list my asignaturas, mallas and niveles, and in the controller MALLA i want to save the arrays to my model
2006 Mar 21
3
Newbie - ActiveRecord relationships
So I''ve worked through Agile Web Development with Rails and I''m now trying my first little app to get into the swing of things. Its a task tracking app where people can create tasks and assign them to others, and also log time against the tasks. I''m having trouble working out the model relationships. This is what I''ve got so far, but its not right as