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
1
vote
1 answer

Rails - How to use Squeel to search through associated attribute

I think this is a simple question: I have a Building model and each Building has_one city and each city belongs_to Buildings. I'd like to perform a search on the Building's city name (not the id) using Squeel. Currently I have: where{(zip =~…
Zephyr4434
  • 796
  • 2
  • 13
  • 25
1
vote
0 answers

rails squeel right outer join

How to make squeel generate RIGHT OUTER JOIN? This: User.joins{comment.outer} generates LEFT OUTER JOIN. No, I cannot do Comment.joins{user.outer}, the whole query is much more complicated and I must start it with User. If not in squeel maybe…
wrzasa
  • 1,113
  • 10
  • 20
1
vote
1 answer

Squeel query syntax to retrieve users' elements sharing the same group

Using Ruby on Rails 3.2.13 and Squeel I have the following models: class Group < ActiveRecord::Base has_and_belongs_to_many :users end class User < ActiveRecord::Base has_and_belongs_to_many :groups has_many :characters, :dependent =>…
McLibboc
  • 73
  • 1
  • 5
1
vote
0 answers

Will Paginate and Squeel not working well together

I'm having trouble making will_paginate work together with squeel. The following code makes a search using params from a form. def self.search(params) if params campo_a_pesquisar = params[:column] item_status_fisico =…
brunocalado
  • 136
  • 7
1
vote
2 answers

How to SELECT DISTINCT [model].* using Squeel and Rails

Out of interest, i was attempting to rewrite Model.joins{other_model}.uniq (which generates): => "SELECT DISTINCT [model].* FROM [model] INNER JOIN [other_model] ON [other_model].[model_id] = [model].[id]" In pure Squeel, however the closest i can…
rwb
  • 4,309
  • 8
  • 36
  • 59
1
vote
3 answers

Finding multiple time slots with Squeel gem

I have a model Planning with a start_time attributes. Say I would like to get all the plannings that are between 9AM and 12PM OR between 6PM and 11PM. Basically I would do: Planning.where do (start_time >= @start_time[0]) & (start_time <=…
Nima Izadi
  • 996
  • 6
  • 18
1
vote
1 answer

Request on PostgreSQL with Rails and Squeel

I was advised to create a new question based on my previous one so here it is : I have on my website a list of product, each user can create his own savings based on these products. So several users can create their own savings based on the same…
Jeremy B
  • 911
  • 7
  • 20
1
vote
4 answers

Squeel request and Heroku, Postgres: Error using GROUP BY and ORDER

I am developing my application with mysql but I am using Heroku to deploy it and am forced to use PG. I have an issue with the following statement: <% current_user_savings = Saving.where{user_id == my{current_user}} %>       <% @latest_savings = …
Jeremy B
  • 911
  • 7
  • 20
1
vote
2 answers

Rails Joins and Like?

I am trying to use joins in rails to retrieve some info base on a search field but I cannot seem to find the good syntax, I have two table savings and product and saving are saving for a product. What I want is to find a saving based on the name of…
Jeremy B
  • 911
  • 7
  • 20
1
vote
1 answer

How to use dynamic attributes / columns in Squeel statements?

In my previous issue I ended up that the following code seems to work as expected: def my_squeel_query table_name = Squeel::Nodes::Stub.new("#{self.class.to_s.tableize}_comment_associations".to_sym) commenters. .where{ …
Backo
  • 18,291
  • 27
  • 103
  • 170
1
vote
3 answers

How to dynamically generate association names?

I am using Ruby on Rails 3.2.2 and the Squeel gem. I have following statements and I am trying to refactoring the my_squeel_query method in a Mixin module (since it is used by many of my models): # Note: 'article_comment_associations' and…
Backo
  • 18,291
  • 27
  • 103
  • 170
1
vote
2 answers

how to join a subquery with conditions in Squeel

Prologue I've embraced Squeel – and enjoying every step! Thank you so much for sharing, Ernie Miller! I'm developing with ruby 1.9.2 and Squeel 1.0.2 and Rails 3.2.5 (I'll confess to having restructured the question entirely - hoping to increase the…
walt_die
  • 580
  • 5
  • 20
1
vote
0 answers

Joining subqueries in Squeel

I'm trying to make some kind of pivotal table, joining one of the model tables (master) with it's many-to-many relations (rel1, rel2, ...), aggregating the number of related models. I'd expect it to produce SQL similar to the following: SELECT …
Alexey Kharchenko
  • 1,032
  • 5
  • 10
1
vote
0 answers

Searching for a entity based on association constraint

I have a model (say User), which has many logins. class User < ActiveRecord::Base has_many :logins end class Login < ActiveRecord::Base belongs_to :user end Would it be possible to find users which have a particular login (say with…
kidoman
  • 2,402
  • 5
  • 26
  • 35
0
votes
1 answer

ActiveRecord, only objects with a nil parent record

I've got a basic forum set up. I want the posts#index action to only show records where parent_post_id is nil, and therefore not a reply post. I've got squeel installed, but I'm not sure if I have it set up right. …
DVG
  • 17,392
  • 7
  • 61
  • 88
1 2 3
8 9