similar to: ActiveRecords Eager Loading

Displaying 20 results from an estimated 7000 matches similar to: "ActiveRecords Eager Loading"

2012 Aug 04
6
Automatic asset paths prevent logical asset organization
In 2fe70c1 (last year), rails changed from a static list of assets.paths to automatically register any path under assets/*. (This was not reflected in Rails Guides so I pushed an update to docrails.) However, in my opinion, these automatic asset paths create confusion. The result is that the first-level directories under `(app|lib|vendor)/assets` get swallowed and if I put assets into a
2006 Apr 24
2
Checkboxes - Saving a Checked record to another table
I am displaying a bunch of records from a table called "assets". Next to each record i have a checkbox. When this box is checked i want to be able to save the id of the record into another table called "flagged_assets". All I need is the ID, nothing else. Im struggling with the logic to save to another table. I know how to do it if the asset_id is already in the
2006 Apr 24
4
Joined search returns NIL ids
I have two models: assets and makes. Make has many assets and an asset belongs to one make. I am calling this part of my asset controller from a search form with the parameters "search" (search term) and "field" (database field heading) which then renders a partial with the search results on it. ######################################################## if
2011 Nov 29
1
ajax question
Hello, could you please explain what''s wrong with this code: Rails 3.1.1 skills_controller.rb class SkillsController < ApplicationController # GET /skills # GET /skills.json def index @skills = Skill.all respond_to do |format| format.html # index.html.erb #format.json { render json: @skills } format.js end end end index.html.erb <%=
2005 Dec 02
3
Conceptual Design Question
Hi All, I am making a DAM (seems to be the hip thing to do these days). It is for the company that I work for. We have some really weird domain rules that have prevented me from just using a simple directory structure file permission system. I have come up with a solution but I wanted to run it by you gurus to ensure that I am not recompiling the wheel here. Basically the domain rule is: A user
2012 Dec 18
2
cache-busting non-digest assets in sprockets in development a good idea? should headers in sprockets be configurable?
Just monkey patched Sprockets in our Rails 3.2.9 app to override the Cache-Control header for html assets that we need to tweak more often in development, but that we don''t want to use digests/fingerprinting with: # Sprockets 2.x patch if Rails.env.development? module Sprockets module Server private alias_method :sprockets_headers, :headers def headers(env,
2007 May 28
2
Rails, respond_to? over anonymous module (extend has_many).
Hello List, I''m trying to generate examples for some list-helpers I have coded which use in my projects. Basically, the Playlist class uses one anonymous module in has_many that acts as helper between acts_as_list and my desired API: class Playlist < ActiveRecord::Base # associations go here has_many :playlist_items, :order => :position, :dependent => :destroy has_many
2012 Mar 20
4
Multiple Paperclip Images on Index
Hi, I am working on a project that is using Paperclip to upload multiple images to an Asset model. my Post model has_many Assets. As per this tutorial/screencast... https://github.com/Emerson/Multiple-File-Uploads-with-Paperclip-and-Rails-3/blob/master/app/views/posts/show.html.erb"> http://www.emersonlackey.com/article/paperclip-with-rails-3> This all works fine and I can
2011 Sep 18
12
3.1 asset pipeline + Capistrano troubles
Hello, I''m having a bit of trouble with the asset pipeline and, I think, Capistrano. In my app layout I have: <%= stylesheet_link_tag "application", "bootstrap" %> And the relevant bits of the app dir structure are: app/assets/stylesheets/application.css.scss # Contains ''require_self'' and ''require_tree .'' as usual
2006 Sep 13
1
Eager loading with acts_as_tree
So I have a model that acts_as_tree and I run a method on a collection of all of these records. This method walks the tree and fetches the parent/children, etc. This results in many, many duplicate SQL queries to be executed. Is there a way to eagerly load all of these models? Something along the lines of: Model.find(:all, :include => [:children, :parent]) If I execute the above statement, I
2012 Feb 15
2
Control number of assets in resulting portfolio with optimizations using package fPortfolio
Dear All, I am using package fPortfolio to run minimum variance portfolio optimizations in R. I already know how to set portfolioSpecs, portfolio objects and constraints. Unfortunately I am not able to set the following type of constraints. I have a timeSeries object with returns data for roughly 1.5k assets for 261 subperiods (workingdays) and want to compute the global minimum variance
2008 Mar 13
3
Refreshing a page gives a "stack level too deep" error.
I''m converting our app into restful rails. A couple of my classes (Resource and Asset) have a has_many relationship with each other - here''s the routes: map.resources :assets, :has_many=>[:resources] map.resources :resources, :has_many=>[:assets] I''m getting something weird in my view pages. When i go to /resources/4/assets it works. I go to the page
2012 Jan 29
1
AssetNotPrecompiledError for missing assets - really?
I migrated one of my projects to from Rails 3.0 to 3.2.1 which means I''m using the asset pipeline for the first time. As much as I like the ease of compressing and minifying my assets the more I''m annoyed about its behavior to raise an AssetNotPrecompiledError as soon as, well, there''s an asset that''s not precompiled. Can somebody explain me the reason why this
2012 Sep 04
10
Generic asset definitions and management
(The following is not a Rails-specific question, but relates to a problem that affects Rails, so I wonder whether anyone on the team has an opinion about it or knows whether a solution is already in development.) While gem dependencies can be easily managed in a Gemfile by Bundler, when it comes to other assets, you either have to manually copy javascript files into the app/assets or vendor
2007 Nov 08
0
Dynamic relation with eager loading
A model has 2 columns in its table asset_type_id asset_id the asset_type_id links directly to the table asset_types via a belongs_to asset_types contains a single column ''name'' method_missing in the model says when you call a method matching /^asset.*/ call the corresponding method substituting ''asset'' for the contents of asset_type.name (ie. the name in
2007 Jun 26
4
Can I stub a method on a belongs_to association:
describe Asset, " when destroyed" do fixtures :assets, :videos, :sites, :publish_settings before(:each) do @asset = assets(:test_asset) @mock_hook = mock("hook") @asset.video.stub!(:hook).and_return @mock_hook # error occurs here end it "should call the delete hook" do @mock_hook.should_receive(:update).with("test_video",
2006 Jul 20
5
How can I make has_many prevent a delete that would lead to orphans?
e.g. class Asset < ActiveRecord::Base validates_presence_of :asset_number, :make, :model, :location, :name, :serial_number validates_numericality_of :asset_number validates_uniqueness_of :asset_number belongs_to :user belongs_to :location belongs_to :asset_type, :foreign_key => ''type_id'' end class Location < ActiveRecord::Base validates_presence_of :name
2013 Oct 12
3
Assets not loading in production
Hello, (Rails 4, Ruby 2) I am trying to deploy my first rails app in a production environment, but cannot get the assets to load. The site is hosted on Webfaction, they advise to create a "static app" to serve the assets which I have done. But I don''t understand how my rails app then knows about the static app. At the moment, in production inside the head it prints out...
2004 Oct 03
1
How might one write this better?
I am trying to simulate the trajectory of the pension assets of one person. In C-like syntax, it looks like this: daily.wage.growth = 1.001 # deterministic contribution.rate = 0.08 # deterministic 8% Wage = 10 # initial Asset = 0 # initial for (10,000 days) { Asset += contribution.rate * Wage
2006 Oct 10
2
Ferret returning too many results
Hi, I just upgraded from acts_as_ferret 0.2/Ferret 0.9.x to acts_as_ferret 0.3/ferret .10.9, and i''m getting a strange behavior: searches are returning far too many results, most of them superflous. i''ll paste in my code below, it''s pretty simple. i''m googling like mad, and going through both the source and the forums, and having trouble finding what could