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
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
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 ?
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
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
Let\'s say I have the following model: # video.rb class Video < ActiveRecord::Base has_many :collection_videos, :dependent => :destroy
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:
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.
I have built a Ruby on Rails application that allows users to track their workouts. User has_many :workouts
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