similar to: Problem using ActiveRecord find with :joins and :select

Displaying 20 results from an estimated 3000 matches similar to: "Problem using ActiveRecord find with :joins and :select"

2012 Apr 02
10
Pessimistic locking locks the entire table?
Hi guys, I must be missing something obvious with pessimistic locking. Here is what I do (Rails 2.3, mySQL): In my Foo model: def test Foo.transaction do lock = UpdateLockForFoo.find_by_foo_id(self.id, :lock => true) sleep 30 end end For each Foo model, I have an UpdateLockForFoo. This "lock" needs to be acquired before doing any changes to Foo. I believe it works,
2013 Feb 25
3
ActiveRecord associations: design question
Hi guys, In my Rails app, I have three models: A, B and C, with the following relationships: - B hasMany C - C belongsTo B I would like A to "has_one" instance of B+C. By that I mean A needs to be linked to a specific instance of B AND a specific instance of C. My first guess would be to create a fourth object, say B_plus_C that would: - belongs to B - belongs to C - belongs to A Is
2013 Jan 03
6
How to avoid simple race conditions with Session?
Here is the situation: - the client makes a request - it is followed by AJAX polling The server needs to keep track of some stuff during this process. I have been using the Session and it "mostly" works… until the user decides to open another tab in her browser and she makes a new, parallel request. In this case, the data from the two requests is merged, which leads to bugs. This got
2006 Apr 20
4
ActiveRecord: Many-to-Many problem
I am trying to make many-to-may relationship on classes Section and Content. Both Content and Section has: has_and_belongs_to_many :contents and has_and_belongs_to_many :sections and I have an exception when trying to access model properties: "undefined method `add_contents'' for #<Section:0xb745c514>" def add_content_entry @section = Section.find(params[:section_id])
2006 Jan 22
2
suggest for "ambiguous column" when JOIN associated tables
Today I face with incorrect behavior in ActiveRecord. It take place when I try to use :include parameter for .find method. Where are two typical cases: 1. You have record with self-referential joins CREATE TABLE keywords (id, group_id); class Keyword < ActiveRecord::Base belongs_to :group, :class_name => "Keyword", :foreign_key =>
2006 Apr 03
2
Order By Number of Comments
Hi, I am new to Ruby on Rails, so I apologise if this has been answered elsewhere. I have had a look through the list but I can''t seem to find what I am trying to do. I have implemented the standard blog and comments app from the screencast. However I am trying to extend the functionality. I want to be able to display a list of posts and order them by the total number of comments
2006 Mar 17
2
Security issue dealing with comment posting - anyone?
This is how I''m posting comments currently. This works, but I read somewhere that I shouldn''t inject params right into my sql query, because it makes it easy for people to hack in and ruin the db. I''m not sure if this even makes sense, but I''ve tried other things, and can''t get anything else to work. #currently def comments content =
2006 May 11
1
Including dynamic list of params in link_to
How do I include all incoming URL parameters (i.e. list_content.rhtml?content_id=23) in my link_to statements? I know I can include specific parameters in the link_to, by using ":variable_name => 123" in the link_to statement... But what If I dont'' know what the incoming parameters will be... and I simply want to include them along with any other specific variables I
2008 Jul 09
2
build matrix with the content of one column of a data frame in function of two factors
Hello, First, thanks for your help (and sorry for my english !) I have a data frame in which each row represents a vote (in percent, only 20,40, 60,80,100) of one person on one content, with three columns : name (the name of the voters), content_id, vote : str(votesredac) 'data.frame': 1000 obs. of 3 variables: $ name : chr "Guillemette Faure" "Guillemette
2012 Apr 30
2
Calendar Integration Problem
Hiii all, I am using asterisk 1.8.9.2 and compile all modules related to calendar. neon version is 0.29.6. OS is ubuntu 11.10. I configured ical for zimbra, caldav for google mail and ews for exchange 2010 calendar. ical and caldav setup working fine and i am getting my calendar events perfectly. But for exchange 2010 calendar i am getting following error. "Unable to communicate with
2006 Jan 13
4
Single Table Inheritance (this is my 3rd post :( )
Hi Everyone, I hope I get some feedback on my question. Here it goes. I have a situation here, I have a company table and then using Single Table inheritance it is of 3 types: class Company < ActiveRecord::Base end class Vendor < Company end class Customer < Company end class Agent < Company end Now I have a active record Association class QuoteSheet < ActiveRecord::Base
2006 Mar 13
5
Displaying related entries by tags - HELP!
Ok, my site is setup like pretty much every other blog out there. A list of the most recent 5 posts, then by clicking one, you go to an individual post page, displaying the full context of that post. Now, what I would like to do is to display the related entries in the side column, which is part of the layout, based on the tags belonging to that specific entry. Here''s my coding so
2009 Nov 25
1
Puppet custom functions and user permissions
Puppet custom functions and user permissions I am busy writing a custom function to automatically add OSSEC agents to a OSSEC server after installation. Unfortunately, it seems that puppetmasterd is not respecting the entries in /etc/group in linux. No matter how many other groups the puppet user has been added to in /etc/ group, when puppetmasterd runs the custom function the effective/real user
2010 Jan 10
3
Need advice: threads or Typhoeus?
Hi guys, I need my app to make a few hundreds requests to external web services as quickly as possible. The web services are fairly fast, but still: if I do the requests one after the other, it is too slow. My understanding is I have two options: a- Threads. b- Typhoeus Typhoeus seems great. Yet, the web services are all quite different (some are SOAP, some REST...) and therefore wrapped into
2012 Aug 23
5
wat is diff between webrat and capybara?????
now i am using cucumber.........and i get two topic webrat and capybara........wat is the diff between them???????which one is good?????which one i use????? Regards Fahim Babar Patel -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2006 Mar 17
1
How to handle errors - HELP
I''m having trouble with my Ajax comments, but only when someone clicks the submit button when there''s no comment. How can I handle this in my code? Do I use "rescue nil" or something? Here''s my controller: def comments content = Content.find(params[:id]) @comment = Comment.new(params[:comment]) content.comments << @comment
2006 May 28
1
ActiveRecord: FK constraints problem
Hi all. I have has_and_belongs_to_many association between models: Section and Content. class Section < ActiveRecord::Base acts_as_tree has_and_belongs_to_many :contents belongs_to :default_content, :class_name => ''Content'', :foreign_key => ''default_content_id'', :dependent => :nullify end class Content < ActiveRecord::Base belongs_to
2009 Feb 19
1
ActiveRecord-2.2.2, association preloading, joins and order parameter weirdness
Hello RoR Groupies, I''m seeing some weird ActiveRecord-2.2.2 SQL generation when doing eager association/preloading and using joins and ordering by said join table. Here''s an example: class Photo < ActiveRecord::Base end class User < ActiveRecord::Base has_one :headshot, :class_name => "Photo" end class Mail < ActiveRecord::Base belongs_to :user end
2014 Aug 12
1
Asterisk 12.4 "Agent Busy" message on AgentRequest
Hi, I am upgrading from Asterisk 1.4 to 12.4. I am able to authenticate the user and call AgentLogin. But after that when I call AgentRequest I keep getting Agent '1234' is busy. If I put a delay of 5 second or more before calling AgentRequest then it works most of the times. Here's my dialplan: [login] exten => s,1,Background(thank-you-for-calling) same =>
2007 Apr 09
1
help with ActiveRecord joins
I''m working on a fairly complex join query and could use a bit of advice from more expert users of ActiveRecord. I have an events table with quite a lot of data, with has_many relations to categories, age_groups, and event_images. In my first naive implementation, each event had a date, so to load all upcoming events efficiently, I''d do: Event.find(:all,