search for: arel_t

Displaying 13 results from an estimated 13 matches for "arel_t".

Did you mean: rel_t
2012 Dec 18
1
Arel limit Where if fields are present
...ng Arel but I''m passing three parameters, I want to include the parameters only if they are different to nil or blank. Here is my method: def self.advsearch(summary_description, specialties, place) User.joins(:experience,:summary,:information) .where(Information.arel_table[:business].eq(false)) .where(Experience.arel_table[:description].matches("%#{summary_description}%") .or(Experience.arel_table[:description].matches("%#{summary_description.capitalize}%")) .or(Experience.arel_table[:job_title].m...
2012 Sep 19
0
How to copy model with arel_table instance
Hi all I want to make copy of current scoped object, then change some stuff in arel_table(i need to change table_alias, because i have complicated query) and arel(SelectManager) def self.do_smth query = scoped.dup puts query.arel_table.object_id == scoped.arel_table.object_id # true end Theoretically i can dup arel(SelectManager) but i can not find how to add table alias to...
2010 Jun 20
0
ActiveRecord and ARel: correlated subqueries?
...ecord in conjunction with ARel. In particular, I''d like to replace my residual literal SQL with ARel, if only I could see how. Let''s take Article with multiple Versions as an example. With ARel alone, I can find articles with their latest versions like this articles = Article.arel_table versions = Article.arel_table articles.join(versions).on(articles[:id].eq(versions[:article_id])). where(versions[:revision].eq( versions.project(versions[:revision].maximum). where(versions[:article_id].eq(articles[:id])))) That doesn''t help me much in the context of Act...
2011 Nov 03
0
Arel table aliases and ActiveRecord::Relation help: how to specify "multiple has_many items in a query"
What is the recommended way to use table aliases with ActiveRecord::Relation these days? In prior versions of Rails, this would work: assume (pseudo code): model A has_many b''s model B ,,, at = B.arel_table atalias = at.alias(at.name + "_1") A.join(:b).join(atalias).where(atalias[:a_id].eq(at[:a_id]).where("b.widget = ''foo''").where("b_1.widget = ''bar''"). ... ^ probably should be "on" now i...
2012 Jan 03
1
Can Arel handle UPPER and LIKE condition?
...mentation, doesn''t seems have any upper/like operator, and check on arel source, under lib/arel/nodes, doesn''t seem to have any node related to this, can arel handl this? Thanks. ps, the arel way of binding value seems to have its own invocation, using eq(xxx), accounts = Account.arel_table Account.where(accounts[:id].eq(1).or(accounts[:id].eq(2))) different from where rails old style binding, like where(:conditions=>[UPPER(name) like ?, ''%#{xxx}%]], so How can I bind them two? -- You received this message because you are subscribed to the Google Groups "Ruby o...
2013 Jul 17
5
Why last doesn't return an ActiveRecord::Relation
Hello, Sorry if this has been still answered, I haven''t found nothing on it. I would love to know why ActiveRecord::Base#last doesn''t return an ActiveRecord::Relation just like all or where since an ActiveRecord::Relation can act more or less like an array (as specified here<https://github.com/rails/rails/commit/0a6833b6f701c8c8febadfe2f45e25df29493602> )? Thanks, have
2012 Jun 08
7
filter children with acts_as_tree
Hello Experts, I have a tree of categories in this category object there is a property called type. the root categories have no type but the children have. so how I can get all the roots with filled in children that have category type = ''B'' for instance. I tried to run Category.roots then delete children With a category not equal to ''B'' but this causes a major
2013 Feb 23
0
where condition having no association
...y :inverse_matches, :class_name => "Match", :foreign_key => :counterpart_id has_many :inverse_counterparts, :through => :inverse_matches, :source => :plan and in the plans_controller, I would like to find a plan (counterpart) having many conditions. plans = Plan.arel_table @counterpart = Plan.where( .... ).where( plans[:user_id].not_eq(current_user.id) # eliminate current user ) in addition to th...
2012 Apr 17
0
Request for adding an "alias"/"as" to ActiveRecord
..._ids_with_children = Field.as(:f1).select(:id).where(id: fields.map(&:id)).where(Field.where(''parent_id = f1.id'').exists) Currently I couldn''t find any solution to work around this issue. For example, suppose this query: field_ids_with_children = Field.from(Field.arel_table.alias(''f1'')).select(:id).where(''f1.id'' => fields.map(&:id)).where(Field.where(''parent_id = f1.id'').exists) This would still raise an error since the default scope will use "condition_type.deleted = ''f''"...
2012 Jan 02
4
Which AR Interfaces Leverage PreparedStatements/Binds?
I could not find the answer to this in a few Google searches and thought I would ask. So when are prepared statements best leveraged in ActiveRecord''s interface? I never really noticed before, but simple condition hashes or scopes do not pass down the binds so that prepared statements are leveraged. So a `Car.find(1)` would but things like `Car.where(:id => 1).first` do not. Is it a
2011 Nov 22
4
A "strict Arel" mode for ActiveRecord to prevent SQL injection vulnerabilities
...with SQL injection bugs, and those bugs don’t particularly stand out in code reviews. For example, Customer.where("name like "%#{params[:id]}%") is vulnerable, while Customer.where("name = ?”, params[:id]) Customer.where(name => params[:id]) Customer.where(Customer.arel_table[:name].matches(''%#{name_pattern}%'') etc are safe. While a careful security code review would likely spot this type of bug, there is still a significant risk that it’d be missed, in particular in an agile project with frequent releases that can’t afford to do an in-depth...
2011 Jul 25
5
Arel quiz: complex queries with associations
I have a real-world application with some complex queries that I want to convert to Arel (as part of an upgrade to Rails 3.1). So that I can understand what I''m doing before I flail around in my real app, I wrote a little sample app (just the models) with some similar associations -- one table joined with itself and more tables that join to another table, so there are some queries that
2010 Oct 30
12
Anyone successfully ran JRuby 1.5.3, Rails 3, Tomcat6
Hi, I''ve been trying to get JRuby 1.5.3 with Rails 3 to run on the Tomcat6 server with little success. Has anyone been able to do this? If so, what issues did you have to overcome to get this to work? Also, is this a combination that you would recommend for a production site, or is it all too new and untested? The latest issue I''m stuck on right now is with the mysql-connector-