named-scope
What is scope/named_scope in rails?
I\'ve recently started an in开发者_高级运维ternship. My employer uses ruby on rails, and I frequently encounter new syntax that I need to look up to understand. I\'ve googled around for a good explana[详细]
2023-02-08 04:43 分类:问答ActiveRecord keeping scope encapsulated
I have two models, foo and bar, foo has many bars. Bar is an event that happens for a given period of time, so I\'d like a method or scope that returns an ActiveRecord::Relation representing the foos[详细]
2023-02-05 21:15 分类:问答Rails: Is that possible to define named scope in a module?
Say there are 3 models: A, B, and C. Each of these models has the x attribute. Is that possible to define a named scope in a module and include this module in A, B, and C ?[详细]
2023-02-05 07:14 分类:问答Using named scope with find_or_create_by
I spent some time figuring this out and haven\'t seen others post on it so maybe this will help someone. Also, I don\'t have much Rails experience so I\'d be grateful for any corrections or suggestion[详细]
2023-02-03 20:57 分类:问答Sorting a Rails database table by a column in an associated model
I\'m trying to implement Ryan Bates\' sortable table columns code (Railscast #228) but I\'d like to be able to sort on an associated column. In particular, I have the following models and associations[详细]
2023-02-03 13:25 分类:问答How can I write two scopes that have colliding joins?
Let\'s say I have the following model: # video.rb class Video < ActiveRecord::Base has_many :collection_videos, :dependent => :destroy[详细]
2023-02-03 01:45 分类:问答How to use a scope in combination with a Model method?
I\'m currently working on some scope filters, and I\'d like to have it filter on a method (don\'t know how to name it otherwise). My code:[详细]
2023-02-02 02:17 分类:问答How would I join to a subselect (a scope) using Rails 3 and Arel?
I need to join a table to the a select/group-by query (which includes the same table), and I\'d like to do it using Arel.[详细]
2023-02-01 14:09 分类:问答How do I filter through an associated resource column using a named_scope?
I have built a Ruby on Rails application that allows users to track their workouts. User has_many :workouts[详细]
2023-01-31 00:25 分类:问答Finding all records containing a specific attribute in rails
I have 2 tables in my app 1. Users, 2. Restaurants. A user can save the names (along with other attributes) of restaurants they\'ve been to. For example user 1 has been to Panda express and Red Robins[详细]
2023-01-30 16:53 分类:问答
加载中,请稍侯......