README.md in sql_query-0.0.2 vs README.md in sql_query-0.1.0

- old
+ new

@@ -7,10 +7,11 @@ # SqlQuery Ruby gem to load SQL queries from `.sql.erb` templates using ERB. It makes working with pure SQL easier with syntax highlighting. + Let's you clean your Ruby code from SQL strings. ## Installation Add this line to your application's Gemfile: @@ -33,14 +34,15 @@ # app/sql_queries/get_player_by_email.sql.erb SELECT * FROM players WHERE email = <%= quote @email %> ``` +`quote` method is an alias to `ActiveRecord.connection.quote` method. You can use it to sanitize your variables for SQL. You can use SQL like this: -```shell +```ruby > query = SqlQuery.new(sql_name: :get_player_by_email, email: 'e@mail.dev') > query.execute (0.6ms) SELECT * FROM players WHERE email = 'e@mail.dev' => [] @@ -67,14 +69,24 @@ ``` ### Methods - **execute** - executes query and returns result data. - - **explain** - runs explain for SQL from template - **sql** - returns SQL string - **pretty_sql** - returns SQL string prettier to read in console -- prepared_for_logs - returns sql string without new lines and multiple whitespaces. +- **prepared_for_logs** - returns sql string without new lines and multiple whitespaces. + +### Configuration + +If you don't like default path to your queries you can configure it in initializer. + +```ruby +# config/initializers/sql_query.rb +SqlQuery.configure do |config| + config.path = '/app/sql_templates' +end +``` ## Contributing 1. Fork it ( https://github.com/[my-github-username]/sql_query/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`)