Questions tagged [active-relation]

A Ruby Relational Algebra Library

Active Relation also known as "Arel" is the Relational Algebra library used in Active Record and Ruby on Rails.

69 questions
0
votes
1 answer

Display records found by ActiveRelation in HTML

I want to display the records returned by following line in html, @var = User.where("first_name like ?", "%"+params[:searchTextField]+"%") How do i display these in html?
user2603796
0
votes
2 answers

Have query working but want ActiveRelation instead

A project has legacy_users and group_users. group_users has to go through groups to get the users. I'd like to build a project.users that combines these queries as an arel. Here is Project: class Project < ActiveRecord::Base has_many …
Dave Bryand
  • 601
  • 6
  • 11
0
votes
1 answer

How to get a collection from a collection in Rails?

I have collection of users with posts, and I'd like to get all the posts from all of the users. Is there a way to do something like this: User.active.posts.unique.visible Active and visible are both special scopes that I've written myself.
Dylan Karr
  • 3,304
  • 4
  • 19
  • 29
0
votes
2 answers

Relationships in Ruby on Rails across 4 models

I am trying to make some advanced relationships in my RoR models. S far what I have working is projects and tasks- Projects have tasks and users have projects. I now want that a user who is 'signed up' to a project can now 'sign up' to tasks within…
0
votes
1 answer

Active Record and Active Relation

What is the difference between active record and active relation in Ruby on rails? Please put the light in very basic terms as i am new to the Ruby on rails and learning it on own.
Ahmad hamza
  • 1,816
  • 1
  • 23
  • 46
0
votes
1 answer

Refining Thinking Sphinx search float field with Active Relation

I have database of products and I use Thinking Sphinx to search through them. I have a pretty complex set of conditions to find the right product in the correct category and details. However, I'd like to refine the search so that I can make…
0
votes
1 answer

Rails ActiveRelation Sub Relation

Im new to rails and have a question about accessing relations of relations in ActiveRecord. Consider this psuedo code: class Organisation has_many: :projects class Project has_many: :tests class Test belongs_to: project Effectively 3 levels. I…
Cheyne
  • 1,964
  • 4
  • 27
  • 43
-1
votes
2 answers

rails scope model without relation

I have such model class Ads::Posting < ActiveRecord:Base has_one :child, class_name: 'Ads::Posting', foreign_key: :posting_id belongs_to :parent, class_name: 'Ads::Posting', foreign_key: :posting_id end I need to write scope which gets all…
-2
votes
1 answer

Do or do not use Ruby on Rails Associations

I am new in RoR , and I wanted to design a web based system. I want to know , if we don't use association in RoR , do happen any problem in system? Please help me and explain me what problem could be happen in such a system. thanks
1 2 3 4
5