Questions tagged [squeel]

Squeel is a "database toolkit" for the Ruby programming language. It extends Active Record with a handy block-based syntax.

Squeel is a "database toolkit" for the Ruby programming language.

It extends Active Record with a handy block-based syntax.

Squeel is available via rubygems.org, the code is available at github.

Examples canm be found at the project website is http://erniemiller.org/projects/squeel

Sequel was primarily developed by Ernie Miller. It is not maintained by him anymore.

Don't mix up squeel with sequel.

128 questions
0
votes
1 answer

Using Squeel or Meta_where with Sinatra

I am using the ActiveRecord stuff in Sinatra and I'm wondering if it will work with meta_where or (preferably) squeel? I'm going to start trying but I was hoping perhaps someone could short circuit me.
jaydel
  • 14,389
  • 14
  • 62
  • 98
0
votes
2 answers

Rails 3 - How to query on a polymorphic belongs_to association with squeel?

I am using acts_as_votable for my questions/answers application. Each question and each answer can be voted (à la stack overflow). I am using squeel and looking for a way to get the following : order the questions from the most voted to the less…
obo
  • 1,652
  • 2
  • 26
  • 50
0
votes
1 answer

Squeel query comparing 2 variables

Using squeel, I'm able to generate the following request Payment.joins(:account => :preference).where({:account => {:preference => {:currency => :currency } } }).to_sql => SELECT "payments".* FROM "payments" INNER JOIN "accounts" ON "accounts"."id"…
0
votes
2 answers

How do I search through associations using Squeel in Rails 3?

I am trying to search through the model contacts associated by user_id but list the companies. @companies_user = Company.joins{contacts}.where{:contact => {user_id => current_user}}.uniq What I want is to search for the names of companies where…
Satchel
  • 16,414
  • 23
  • 106
  • 192
0
votes
0 answers

How to cast ID field to text in squeel query

I essentially want to perform a LIKE query on a PostgreSQL primary id column for a query generated using Squeel and I don't think Squeel is understanding the syntax I'm giving it. Any ideas? Active Record Task.where("(id::text LIKE ?)",…
Thomas
  • 2,622
  • 1
  • 9
  • 16
0
votes
2 answers

MetaWhere to Squeel migration

In MetaWhere I combined conditions to sql variable using loops, if else statements. sql = {} email_starts_with = "vany%" sql["growth"] = 0..200 sql = sql & (:rating > 50) sql = sql & (:email =~…
vany
  • 421
  • 1
  • 3
  • 13
0
votes
1 answer

Calling PostGIS functions within Ruby

I need to execute the PostGIS function st_intersection within an SQL SELECT clause in Ruby. At the moment I am doing it as raw SQL query: sql_query = "SELECT id, ST_ASEWKT(ST_INTERSECTION(geometry, ?)) FROM trips WHERE…
Patrick
  • 1,046
  • 2
  • 10
  • 31
0
votes
1 answer

ActiveRecord: Loading records with all child association eager loaded, but select the ones that any of the children hits the condition

I have models like the following. class Project < ActiveRecord::Base # id :integer # name :string has_many :assignments end class Assignment < ActiveRecord::Base # id :integer # finished :boolean #…
Ryo
  • 2,003
  • 4
  • 27
  • 42
0
votes
1 answer

Unable to write validations for dates in Rails

I'm trying to validate the dates in my Rails app. I'm using jQuery Datepicker to choose starting and ending date for booking in a library. I want to check before creating new reservation, that there isn't any other reservation in the db, which would…
Jes
  • 323
  • 2
  • 18
0
votes
1 answer

Deprecation Warning for Squeel load_core_extensions

in one of my applications I get the annoying deprecation warning of squeel all the time. DEPRECATION WARNING: Core extensions are deprecated and will be removed in Squeel 2.0. (called from app/config/initializers/configurations/squeel_init.rb:13:in…
Sebastian
  • 1,873
  • 4
  • 25
  • 57
0
votes
2 answers

Using AND conditions and Between in Rails Scopes

I'm trying to create a scope to return all records that fall between a certain range and date. I have a method that accomplishes this but I'm trying to refactor it. Original Method: def self.find_by_time facility_id, start_time_string …
Batman
  • 5,563
  • 18
  • 79
  • 155
0
votes
1 answer

Changing from joins to includes breaking query

I had this working query: @search = Availability.joins{facility.activities} .where{activities.id == s_activity} But my view was getting a lot of information from Facilities and this resulted in an N+1 issue. So I decided I should be using includes…
Batman
  • 5,563
  • 18
  • 79
  • 155
0
votes
1 answer

Querying average with a function of column in Rails

I'm using Rails 4 in a web app, Postgresql database and squeel gem for queries. I have this function in my model statistic.rb def properties_mean_ppm(mode, rooms, type, output_currency_id) sql_result = properties(mode, rooms, type).select{ …
xhenryx14
  • 704
  • 6
  • 10
0
votes
1 answer

Rails: What is 'my' in ActiveRecord where class

It's very strange. I don't see any documentation for the usage of 'my' in where class. Can anyone please explain the below. 1.9.3-p547 :006 > reser = Date.today => Thu, 18 Dec 2014 1.9.3-p547 :011 > Reservation.where { start_date >= reser }.count …
Mr. Black
  • 11,692
  • 13
  • 60
  • 85
0
votes
0 answers

Rails 4 Active Record 2 different relations same model scope

I have these models: SpaceShip < ActiveRecord::Base has_one :martian has_many :people Person < ActiveRecord::Base has_many :skills Martian < ActiveRecord::Base belongs_to :skill Skill < ActiveRecord::Base #rest omitted I need to have a…
CV-Gate
  • 1,162
  • 1
  • 10
  • 19
1 2 3
8 9