Summarized using AI

ActiveRecord can't do it? Arel can!

Prathamesh Sonpatki and Vipul Am • June 26, 2014 • Singapore • Talk

The video titled 'ActiveRecord can't do it? Arel can!' features speakers Vipul Am and Prathamesh Sonpatki, who discuss the capabilities of Arel, a SQL generation library used in Ruby on Rails applications. The session, held at the Red Dot Ruby Conference 2014, aims to explore how Arel can help developers create complex SQL queries that may not be achievable through Active Record alone.

Key Points Discussed:
- Introduction to Arel: Arel is introduced as a powerful SQL generator for Ruby that allows developers to construct complex queries without writing raw SQL.
- Active Record Limitations: The speakers mention that while Active Record provides an excellent interface for database interactions, it has limitations when it comes to complex SQL queries, particularly when developers need more intricate control over their SQL.
- Practical Examples:
- Using Arel for Query Construction: They demonstrate various ways to use Arel for creating queries such as filtering for specific cuisines and comparing multiple attributes, showcasing how Arel simplifies the process.
- Complex SQL Features: They illustrate using Arel for complex SQL operations such as negative predicates, intersections, and joins, including self-joins on the same table.
- Integration with Active Record: It’s highlighted that Arel can be seamlessly integrated with Active Record, allowing developers to leverage both libraries for enhanced SQL capabilities.
- Window Functions: The talk includes a brief mention of upcoming features in Arel related to SQL window functions, which will allow grouping and advanced querying.

Conclusion and Takeaways:
- Arel enhances the power and flexibility of database queries in Rails applications, especially when Active Record falls short.
- By incorporating Arel, developers can construct complex predicates and subqueries in a more manageable and systematic way than using raw SQL directly.
- The speakers encourage developers to experiment with Arel to improve their SQL querying ability within Ruby on Rails applications, underlining its advantages for creating cleaner and more maintainable code.
- The session concludes with appreciation for the original creators of Arel and the continued development of its features, inviting interested developers to explore the linked app at the conference.

ActiveRecord can't do it? Arel can!
Prathamesh Sonpatki and Vipul Am • Singapore • Talk

Date: June 26, 2014
Published: unknown
Announced: unknown

Active Record is awesome. But how does ActiveRecord handle generating complex SQL queries? Under the hood it's handled by Arel. Most of the time, Rails developers don't have to know about how Arel works.

But sometimes Active Record can't satisfy our needs. Also Arel has many strengths not exposed through Active Record.

Let's experiment with Arel directly and wield great SQL power in database agnostic way.

Red Dot Ruby Conference 2014

00:00:03.760 uh
00:00:19.760 hi uh
00:00:21.119 good afternoon
00:00:22.400 so uh
00:00:24.320 we are going to speak on uh lots of
00:00:26.800 things
00:00:28.560 on aerial today it will be kind of an
00:00:30.480 interview sorry it will be kind of a
00:00:32.160 learning session for me uh
00:00:34.079 uh from prathamesh and we'll try to
00:00:36.239 explore a lot of lots of things uh
00:00:38.399 which are
00:00:39.360 not kind of exposed exposed through
00:00:41.200 active record
00:00:42.800 so
00:00:43.680 i'm prathamesh sorry
00:00:46.719 i'm prathamish yeah and
00:00:51.280 i'm so sorry
00:00:55.840 this was this was not supposed to be the
00:00:57.680 joke
00:01:00.079 so we
00:01:01.680 actually uh we work at a we work
00:01:03.600 together at a consultancy name that's
00:01:05.040 big binary and it's based out of miami
00:01:07.920 and we have we are from pune
00:01:10.640 where we work remotely with the
00:01:12.000 constituency over there and we got to
00:01:14.000 know each other a lot uh from rails uh
00:01:16.479 while working on uh rails code code base
00:01:18.720 actually
00:01:20.400 so
00:01:21.439 yeah uh some of the fault like uh why i
00:01:23.840 read that was
00:01:25.119 it has been quite hectic getting over
00:01:27.040 here and i could not get get sleep last
00:01:29.119 uh last night and we are currently
00:01:30.880 staying at this hostel uh named as plot
00:01:34.079 and
00:01:34.960 yeah it's been quite hectic
00:01:40.079 so
00:01:40.799 what are you working on these days
00:01:43.040 okay this is actually the uh
00:01:44.799 conversation part so
00:01:47.360 yeah
00:01:50.240 okay so what are you working on these
00:01:51.840 days uh you see i'm working on a pretty
00:01:55.280 hot startup which is like backpackers
00:01:57.360 llc and i've been traveling to a lot of
00:01:59.520 places recently uh where i find where
00:02:02.159 i've made a lot of uh
00:02:03.759 where i've met a lot of friends from
00:02:05.200 hostels and they're backpackers and i
00:02:06.799 wanted to help them out in some ways so
00:02:08.560 i'm working on this app uh which which
00:02:10.560 does basic basic functionalities and it
00:02:12.640 helps them out in like maybe task
00:02:14.239 management or finding great locations
00:02:16.879 finding food centers or finding cheap
00:02:19.280 hostels in hotels looks good yeah and
00:02:22.319 you know it has a very special feature
00:02:23.920 also like it can it can help you out to
00:02:26.080 find lost bags
00:02:28.160 so
00:02:28.879 yeah
00:02:29.680 and
00:02:30.560 special mention over here like you
00:02:31.840 should go over this handle and start
00:02:34.239 following this because it needs more
00:02:35.599 followers
00:02:38.239 and
00:02:40.080 yeah
00:02:41.280 and we already have uh pretty happy
00:02:43.040 customers right now who use our uh you
00:02:45.519 who use our app and yeah this is one of
00:02:47.519 the one of the features like which help
00:02:49.519 them to find the bag
00:02:52.800 so
00:02:53.519 just to give rather mission overview
00:02:55.120 like i'm working on pretty hardcore
00:02:56.640 stuff and some of the things that i work
00:02:58.400 on like i have this traveler model over
00:03:00.319 here which is encapsulates data from
00:03:02.480 about the traveler uh something
00:03:05.519 i have tasks which handles information
00:03:07.200 for tasks locations for finding
00:03:08.879 different information about locations
00:03:10.480 and
00:03:11.120 bookings associated with the customers
00:03:13.040 and things like that cool looks good and
00:03:15.360 you know what it's like it's the current
00:03:17.120 hotness and i have like 10 active users
00:03:19.360 right now wow and i just launched it
00:03:21.680 last
00:03:22.720 yeah i launched it last week and i
00:03:24.959 actually have 10 active users so you you
00:03:27.840 actually can go at
00:03:29.799 backpackers.heroquap.com and you can
00:03:31.360 sign up yourself
00:03:33.040 and it's actually live app
00:03:35.680 and so while i was working like i have
00:03:37.440 10 actual users so
00:03:39.519 performance was the most important thing
00:03:41.920 for me like you know 10 active users you
00:03:44.480 don't get that much these days so yeah
00:03:47.680 so that's why i'm i was very pretty much
00:03:50.239 into hardcore sql stuff so i'm like
00:03:53.360 everything that you can't get through
00:03:54.959 active recorder i would i try to do it
00:03:56.400 through raw skills because you know
00:03:57.840 actual power of database it should it's
00:03:59.680 it's pretty important so yeah i used a
00:04:02.000 lot of raw sequel and it was you know
00:04:04.879 i'm into i'm i'm a lot into uh
00:04:07.840 sql so yeah it's pretty simple for me
00:04:10.560 but you know what sometimes uh
00:04:13.360 i don't know it's sometimes it's pretty
00:04:14.959 hard for me uh using it in active record
00:04:18.239 okay so yeah so like this is an example
00:04:21.120 that i was working on which
00:04:23.199 uh tries to
00:04:24.639 what it does is it's trying to find out
00:04:27.600 cuisine
00:04:29.040 it so for my friends it tries to find
00:04:31.199 out food or
00:04:33.040 places where
00:04:34.240 we can find indian cuisine
00:04:36.720 and what it tries to do is it's using i
00:04:38.479 like over here because you know i didn't
00:04:40.240 like the where clauses and things like
00:04:41.520 that and i wanted to draw a sql so yeah
00:04:43.680 i'm doing pretty hardcore stuff over
00:04:45.120 here
00:04:46.400 oh you have heard of errol
00:04:48.560 uh yeah i've heard of it but i didn't
00:04:50.400 use because you know hardcore raw sequel
00:04:52.080 stuff okay
00:04:53.680 so let me tell you how we can improve
00:04:55.520 this query using errol so
00:04:57.840 erl is actually sql generator for ruby
00:05:00.800 it can generate all kinds of complex sql
00:05:03.600 in object oriented way you don't have to
00:05:05.360 write raw sql for that and it is used by
00:05:08.160 activerecord internally but it has all
00:05:11.600 the other features which are not exposed
00:05:13.360 by default by active record api so in
00:05:16.320 your scenario errol can help you so
00:05:18.880 let's start
00:05:20.080 yeah
00:05:21.120 so the first thing that we have to do is
00:05:23.199 we have to first grab the underlying
00:05:25.199 object okay
00:05:26.720 every active record uh of model will
00:05:29.280 have this method error table and using
00:05:31.600 which we we can grab the underlying
00:05:33.680 error object okay so once we got that
00:05:36.880 object why do you have this table aerial
00:05:38.639 table thing uh because it can give you
00:05:41.039 access to the underlying error object
00:05:42.960 and you can call errol methods on that
00:05:44.639 otherwise they are not exposed directly
00:05:46.960 through active record api
00:05:49.600 so once you have got that object you can
00:05:52.240 call methods like this where you are
00:05:54.080 accessing the cuisine attribute and you
00:05:56.080 are calling matches any which is like
00:05:58.479 it is doing the same stuff that you did
00:06:01.039 by writing raw sql i like an r so this
00:06:03.600 is the aerial thing that you're speaking
00:06:04.800 about yeah right this is the errol
00:06:06.479 predicate method uh so you're matching
00:06:09.360 uh your cues in attribute over your
00:06:11.199 arguments and you can pass any number of
00:06:13.600 arguments sorry so
00:06:15.520 um it has generated the or clause for
00:06:17.759 you because you are doing matches any
00:06:19.759 okay and as your most probably you are
00:06:22.160 using postgresql so it has generated the
00:06:25.199 i like also you don't have to remember
00:06:26.880 that i like so it is database agnostic
00:06:29.520 this looks interesting yeah
00:06:31.440 so let me ask you one more question oh
00:06:34.000 don't don't look at the slide sorry
00:06:37.280 okay so
00:06:38.800 so let me ask you one more question can
00:06:40.720 your app handle this condition where you
00:06:43.039 want indian food also but you want
00:06:44.880 vegetarian indian food yeah so
00:06:47.759 whatever like my app is the current
00:06:49.600 hotness so i have current like whatever
00:06:52.160 this is like pretty basic stuff that my
00:06:54.000 app is able to do so what i'm basically
00:06:56.880 doing is you know i use the i like so
00:06:59.039 i'm using just not i like over here and
00:07:00.720 it's filtering out all the results for
00:07:02.639 a non-veg food okay yeah it's like
00:07:05.919 you know whatever but erl can help you
00:07:08.319 in this also so
00:07:10.080 as it has matches it also has does not
00:07:12.319 match so it can generate negative
00:07:14.080 predicates also and using that you don't
00:07:17.120 have to write that not like i like raw
00:07:19.360 sql oh
00:07:20.880 that's interesting yeah and not just
00:07:23.039 this it has all this full list of
00:07:25.199 predicates you can do lots of stuff here
00:07:27.360 you can
00:07:28.400 compare on arrays you can do
00:07:30.960 greater than less than greater than
00:07:32.560 equal to less than equal to you can do
00:07:34.479 lots of predicates looks interesting
00:07:37.120 yeah and it's very simple you don't have
00:07:38.880 to do much for this
00:07:41.360 uh wait but this is like pretty basic
00:07:44.240 stuff i mean it's possible to do it in
00:07:46.319 groovy also like equals two and stuff
00:07:47.840 like that i mean it's not not not so
00:07:49.919 hard
00:07:50.960 can
00:07:51.759 ariel do like kind of hardcore stuff
00:07:54.560 that i'm doing over here because like
00:07:56.319 i'm into
00:07:57.440 raw sequel so i'm doing an intersect
00:07:59.199 over here is it possible to do that yes
00:08:01.039 it is also possible so
00:08:03.199 i think what we will have to do here is
00:08:05.199 we will have to break this complex query
00:08:06.960 into different parts and errol can
00:08:08.639 easily do that
00:08:09.919 uh would you like me to explain what is
00:08:11.599 what this is doing yeah so it's trying
00:08:13.039 to uh what this is doing is it is trying
00:08:15.360 to
00:08:16.080 uh
00:08:17.199 find all the locations with bookings for
00:08:19.759 a book uh i mean whichever location
00:08:21.280 which has a booking and then on top of
00:08:23.199 that it is going to find locations uh i
00:08:25.440 mean it is going to find a result of the
00:08:27.840 ratings which uh for locations which are
00:08:30.000 greater than three okay
00:08:31.840 and that's why i'm using intersect over
00:08:33.200 here okay so you you want to combine the
00:08:35.519 result of both the sub query exactly
00:08:37.360 right so let's start with your booking
00:08:39.120 query the rating should be more than
00:08:40.959 three right yeah so we we can use our
00:08:43.440 greater than predicate to generate this
00:08:45.200 clause and let's just keep it as it is
00:08:47.440 we will use it later
00:08:48.880 so let's move next now we want to join
00:08:51.680 so here we will not join using active
00:08:53.839 record way
00:08:55.120 when you are joining using active record
00:08:57.040 active record will take care of matching
00:08:58.880 the primary keys and foreign keys
00:09:00.560 automatically but as you are doing errol
00:09:03.040 way
00:09:03.839 you you have to go in steps so first you
00:09:05.920 pass the review tables errol object then
00:09:08.880 you specify on which condition you want
00:09:10.800 to join so
00:09:12.800 you specify that you want to join
00:09:15.279 reviews location id column it should be
00:09:17.120 equal to location's primary key
00:09:19.200 and now you can specify one more extra
00:09:21.360 join condition so this is not possible
00:09:23.519 by default in activerecord you have to
00:09:25.519 write sql for that
00:09:27.360 but here you can specify the extra join
00:09:29.360 condition where we are using that our
00:09:31.200 existing clause
00:09:32.720 and now once we have generated this
00:09:35.279 join condition
00:09:36.399 now we want to select something from it
00:09:39.120 so as errol is based on relational
00:09:41.200 algebra it has some relational algebra
00:09:43.440 terms so select in sql it's similar to
00:09:46.240 project in error so you are projecting
00:09:48.880 star error.star which gets converted
00:09:51.440 into sql literal yeah i know about the
00:09:53.680 stars it's like select star yeah you
00:09:56.080 know sql
00:09:58.080 okay
00:09:59.279 and the join method is not just inner
00:10:01.360 join so if you want to do outer joins in
00:10:03.760 active record it's not possible by
00:10:05.839 default but here errol join method can
00:10:08.480 take a second argument
00:10:10.080 by default it will be inner join always
00:10:12.320 but you can pass outer join you can pass
00:10:14.320 right outer join full outer join and it
00:10:16.240 will do those joints also so joints are
00:10:19.200 very simple using aerial
00:10:21.200 wait we were not discussing on joints
00:10:23.839 please focus okay let's come back let's
00:10:25.680 come here we were speaking about
00:10:26.800 intersect yeah i don't see that over
00:10:28.320 there okay so now we have got our two
00:10:31.040 queries sub queries
00:10:32.399 and now we want to just do the final
00:10:34.160 step
00:10:35.040 and let's do that it's very simple
00:10:38.480 so just combine them using intersect
00:10:40.079 you're done
00:10:41.920 that looks simple so here i'm using join
00:10:44.480 which is from aerial and then i'm doing
00:10:46.640 joints which is from activerecord right
00:10:49.200 and
00:10:50.320 it works because of errol actually so
00:10:53.360 how it works is the intersect method is
00:10:55.279 defined in errol select manager so you
00:10:57.680 want the earlier clause
00:11:00.160 the result you can chain on that clause
00:11:02.560 and the intersect method works in this
00:11:04.800 way that you can pass any object to it
00:11:07.120 which responds to ast and here location
00:11:10.079 dot joins bookings responds to st so
00:11:12.800 errol will convert this into its ast and
00:11:16.000 will apply the intersect method on both
00:11:18.399 nodes that looks interesting
00:11:20.320 yeah you get the same query back
00:11:22.640 wow it's it's much cleaner than what i
00:11:25.040 had written like the ros equal stuff and
00:11:26.720 it's exactly exactly it looks good yeah
00:11:29.680 and it's just not just uh intersect you
00:11:32.160 can do unions also you can do accept
00:11:34.240 clauses also so you can combine your sub
00:11:36.560 queries in all possible ways i mean i
00:11:38.720 don't want to use those but yeah fine
00:11:40.160 whatever okay uh
00:11:43.600 fine i mean
00:11:45.040 that's that's okay it's just basic
00:11:47.519 intersect that you're using but you're
00:11:49.040 not convinced yet
00:11:50.640 i'm i'm using pretty hardcore stuff that
00:11:52.399 i told you okay so here's one one
00:11:54.240 another thing like i'm using uh i just
00:11:56.320 i'm using the stable as adjacency list
00:11:58.240 and what it's trying to do is it is
00:11:59.839 having uh so i'm trying to do uh provide
00:12:02.640 a self join over here like the there's a
00:12:04.560 parent location there may be locations
00:12:06.320 and sub locations okay and i'm doing
00:12:08.079 this you know using hardcore raw sequel
00:12:10.639 stuff like you know inner join on the
00:12:12.320 same table okay using the alias and
00:12:14.560 things like that
00:12:15.839 and i'm i don't think that okay this is
00:12:17.760 possible through aerial well it is also
00:12:19.839 possible through it so let's see that
00:12:22.079 the first thing that we want to do is we
00:12:23.920 want to create alias on our existing
00:12:25.920 table and it's just a simple method
00:12:28.079 alias you call that method and you get
00:12:29.839 alias for your table okay so we created
00:12:32.480 the alias for nearby locations now let's
00:12:35.040 do the join
00:12:36.800 so in previous case we joined on a
00:12:39.360 review table but here we will join on
00:12:41.760 our own alias so location will join on
00:12:44.240 nearby locations and then you can just
00:12:46.320 specify your join condition as we did
00:12:48.720 last time
00:12:49.920 and again you can pass the extra end
00:12:51.600 condition okay
00:12:53.279 and what is this join sources that i'm
00:12:54.560 seeing over here yeah so the uh if you
00:12:57.279 want to pass this to activerecord joins
00:12:59.440 method you want the internal join object
00:13:02.240 okay and this join sources what it does
00:13:04.560 is it it gets that internal object
00:13:07.760 the object is now pluggable so you can
00:13:10.160 pick it up plug it into joins method you
00:13:12.639 get your active record relation object
00:13:14.880 back okay something like this what
00:13:16.240 you're doing over here yeah something
00:13:17.839 like this so uh you combine the result
00:13:20.720 pass it to activerecord joins method and
00:13:23.040 you get the same sql
00:13:25.120 but notice the difference uh here you
00:13:26.959 are getting the table name as locations2
00:13:29.360 which is generated by error the alias
00:13:31.440 one right so you don't have to uh
00:13:34.560 like make sure that you are using a
00:13:36.399 unique name serial will do that for you
00:13:38.639 nice
00:13:40.480 again
00:13:41.519 i don't have to say anything
00:13:43.440 i think it's getting quite boring using
00:13:45.200 the slide again again okay
00:13:47.360 but anyway so yeah
00:13:49.760 this is all fine this is all uh raw
00:13:51.920 sequel stuff but yeah you know
00:13:53.760 i'm using pretty secure i'm i mean i
00:13:56.240 have 10 users so i needed to make it
00:13:58.079 super secure so i'm using like hardcore
00:14:00.720 again database stuff i didn't want to do
00:14:02.320 the ruby stuff because i i believe on
00:14:04.639 database so i'm using this thing i'm
00:14:06.880 using these functions like you know pg
00:14:09.040 sim encrypt which is i mean i'm trying
00:14:10.959 to directly encrypt data directly from
00:14:12.560 the database so
00:14:14.000 yeah i have these set and get methods
00:14:15.920 which are uh using getting the key and
00:14:18.240 value they are directly encrypted data
00:14:20.000 from database and just associating it to
00:14:22.160 that particular record and you can see
00:14:23.760 over here
00:14:25.040 just running that query executing it and
00:14:28.560 you know this is pretty hardcore i don't
00:14:30.000 think it will be possible i mean
00:14:32.240 i don't see why errol should come into
00:14:34.000 this picture
00:14:34.959 okay so errol has an answer to this also
00:14:38.000 okay the concept of name functions so
00:14:40.560 what name functions are they're like
00:14:42.560 they will act as a rapper ruby wrapper
00:14:44.480 for your sql functions so you just pass
00:14:47.279 the database function name and its
00:14:49.760 arguments and then you will get a name
00:14:52.160 function back which you can use in your
00:14:54.079 select query just like you use your
00:14:56.079 normal attributes so yeah eril can help
00:14:59.120 you in this also
00:15:02.079 and i see one more use case what are
00:15:04.480 what are you trying to do here
00:15:06.240 ah see again hardcore
00:15:08.560 sequel stuff i am using koalas over here
00:15:11.040 like i mean some some of the time uh my
00:15:13.199 users want to sort uh sort tasks based
00:15:15.839 okay when they were completed and
00:15:17.360 sometimes the completed ad time that i
00:15:19.120 have over here it may not be present
00:15:20.800 over here so instead of that i'll be uh
00:15:22.800 sorting on created ad that's why i'm
00:15:24.240 using coalis okay so you can use name
00:15:27.120 functions here also let me show you okay
00:15:30.320 so just like previous we defined the
00:15:32.480 name function for order criteria and we
00:15:34.800 can pass that to our order clause and it
00:15:37.199 will generate the same query so name
00:15:39.680 functions can be used in these scenarios
00:15:41.760 you just don't have to rely on select
00:15:43.600 you can use it in multiple cases depends
00:15:46.000 on what function you want to use
00:15:48.399 pretty interesting
00:15:50.160 yeah
00:15:50.880 i mean this has been quite informative
00:15:52.720 and you know what i'm going to try and
00:15:54.800 uh hack into my app and start using this
00:15:56.800 little stuff and it was pretty nice okay
00:15:59.600 so let me give you a summary for it
00:16:01.839 right so let's just summarize all the
00:16:03.440 things that we discussed uh we discussed
00:16:05.759 complex predicates you can do all kinds
00:16:08.000 of positive stuff negative stuff you can
00:16:09.759 generate remember you can chain them
00:16:12.399 then combinations you can generate your
00:16:14.480 sub queries you can combine them using
00:16:16.320 intersect union
00:16:17.920 accept all kinds of possible
00:16:19.519 combinations and joints joints do you
00:16:22.560 can do inner join self joints you can do
00:16:25.279 outer joins okay all kinds of possible
00:16:27.920 possibility it's possible
00:16:30.240 and then the last part that what we seen
00:16:32.880 was you can use errol with active record
00:16:35.279 right so
00:16:36.800 uh
00:16:37.600 you can leverage the existing active
00:16:39.600 records features
00:16:41.120 with the power of errol
00:16:42.800 man this was quite informative and
00:16:44.399 thanks thanks for all i mean giving
00:16:46.160 giving an idea of whatever whatever i'm
00:16:47.920 able to use through erin
00:16:50.320 don't thank me actually thank these
00:16:51.839 people so nick kellan originally wrote
00:16:54.800 erl then bran and emilio they integrated
00:16:57.680 it into rails in summer of code and
00:17:00.160 aaron and ernie for adding new features
00:17:03.440 maintaining and everything thanks
00:17:06.240 can we have a clap for them
00:17:14.319 yeah
00:17:15.679 yeah uh talk was short because there was
00:17:17.919 tea break so
00:17:19.760 yeah that's about it uh
00:17:22.480 there's one thing that
00:17:24.480 yeah the conversation is over actually
00:17:26.319 so there was one another thing that we
00:17:27.679 wanted to include which was windows
00:17:31.120 so if you must have used windows uh in
00:17:34.080 sql it's possible again through aerial
00:17:36.559 to use in a pretty neat way so this is
00:17:39.039 how actually uh ray aerial works behind
00:17:41.600 the scenes it creates a select manager
00:17:43.760 and this is a this is the engine i mean
00:17:46.400 every model that you have it has a
00:17:47.919 engine associated that is
00:17:49.600 an active record related uh
00:17:52.000 object
00:17:52.960 and
00:17:53.919 we can use things like window over here
00:17:56.880 so it it is
00:17:58.480 it is something that is useful when you
00:17:59.919 want to group together your results
00:18:02.000 uh so this is a running pr right now i
00:18:03.919 mean uh
00:18:05.360 aaron is over here maybe he can take a
00:18:06.799 look so we'll have this functionality uh
00:18:09.840 complete functionality of windows
00:18:11.840 possible through erl also
00:18:15.679 the code that we have in the slides is
00:18:17.520 available on github at
00:18:19.919 this particular url and yeah the app is
00:18:22.160 live actually and you can start using it
00:18:24.000 at backpackers.herocap.com
00:18:27.280 maybe you can check it out
00:18:29.120 yeah that's it
00:18:36.480 i'm sorry
00:18:40.880 so the question is um
00:18:43.120 are some of these were you will you
00:18:44.559 agree that some of these examples are
00:18:46.160 simpler in sql than in ariel
00:18:50.240 i mean
00:18:52.000 if it was sequel uh simpler it would you
00:18:54.400 would you wouldn't even use active
00:18:56.000 record yeah i mean in that terms but
00:18:58.559 yeah
00:18:59.760 in lots of cases it seems simpler in the
00:19:02.160 beginning but in the end it's like you
00:19:04.160 are adding on lots of conditions and it
00:19:06.080 gets quite messy uh
00:19:08.400 there are also other things involved
00:19:09.840 that you need to take care of uh whether
00:19:12.640 the syntax is correct or you have actual
00:19:14.720 coating correct or things like that
00:19:16.320 which are given by free for us uh from a
00:19:19.440 from aerial and active record so things
00:19:21.679 like that are pretty useful for us
00:19:24.160 and again it's again a thing of like
00:19:26.640 your it helps us out to reuse a lot of
00:19:29.120 thing that we are i mean we are breaking
00:19:30.720 a lot of things into smaller chunks
00:19:33.360 so
00:19:34.160 imagine a case that you have a big query
00:19:36.559 and
00:19:37.280 you're writing it in one single line
00:19:38.720 instead of that you can actually break
00:19:40.240 it down into a separate class and then
00:19:42.559 you can have a pretty decent uh test i
00:19:45.120 mean you can have a pretty decent test
00:19:46.880 for that particular class so
00:19:49.280 yeah
00:19:50.720 and then again uh you can combine all
00:19:53.280 these results and use them again in
00:19:55.360 terms of active record just like we did
00:19:57.039 for joins so you leverage what active
00:19:59.760 record does for you so you can chain on
00:20:01.520 those in uh other active record which so
00:20:04.400 your one class can be rel and other
00:20:06.160 clause can be normal active record way
00:20:08.240 but still you can
00:20:09.760 chain on them
00:20:12.559 okay
00:20:13.760 have you been trying the sql library and
00:20:18.400 how do you find it
00:20:19.760 comparable to to rl
00:20:23.200 so i think we both have not used sql we
00:20:25.840 are not used sql but one of the
00:20:27.600 advantage of uh
00:20:29.120 using arl is that it's under the rails
00:20:32.480 umbrella so
00:20:36.720 you can be like
00:20:38.559 somewhat sure that okay
00:20:41.200 so you you wanted to
00:20:43.600 to make
00:20:45.520 inside of rails inside effective records
00:20:48.080 so this is because
00:20:50.720 it's aligned with that actually
00:20:52.559 okay
00:20:53.440 okay thank you
00:20:55.200 thanks prater mesh and vipul um
00:20:58.159 yeah thanks
00:21:26.799 you
Explore all talks recorded at Red Dot Ruby Conference 2014
+20