Re: [Rails-core] [Feature][ActiveRecord] `where.or` query method

2019-10-10 Thread T.J. Schuck
> I usually resort to using Arel for more complex queries; not as straight
forward at first, but very powerful I find.

Please note that Arel is a part of Rails' private API, so its direct usage
is not encouraged, since it could change in breaking ways at any time.

(See the Rails docs on what constitutes private/public API, since it's not
as simple as `private` scope:
https://guides.rubyonrails.org/api_documentation_guidelines.html#method-visibility
— Arel is even used for the example of "don't use this private thing".)

On Thu, Oct 10, 2019 at 11:07 AM Andrew Kaspick  wrote:

> I usually resort to using Arel for more complex queries; not as straight
> forward at first, but very powerful I find.
>
> On Thu, Oct 10, 2019 at 10:15 AM Kevin Deisz 
> wrote:
>
>> For more complex queries, so syntactic sugar can make this a little more
>> palatable:
>>
>> Author.some.complex.scopes.then { |relation| relation.where(first_name:
>> 'John').or(relation.where(last_name: 'Smith')) }.more.complex.scopes
>>
>> Even better is just extracting that to its own named scope,
>>
>> scope :named, ->(first_name, last_name) { where(first_name:
>> first_name).or(where(last_name: 'Smith')) }
>> Author.some.complex.scopes.named(first_name,
>> last_name).more.complex.scopes
>>
>> I get that that doesn't solve your concern with the API, but it makes it
>> more readable for sure.
>>
>> On Thu, Oct 10, 2019 at 9:03 AM Rolandas Barysas 
>> wrote:
>>
>>> I think the idea of making `or` simpler is welcome, but I'm not fond of
>>> this implementation. Passing multiple parameters implies that we're using
>>> them together (like `.not()`), but in this case it implicitly uses
>>> parameters separately (using as an or, that is).
>>>
>>> I think something like this would be more readable:
>>>
>>> Author.where(first_name: 'John').or(last_name: 'Smith')
>>>
>>> Right now in your particular case you can write like this, though I
>>> assume you're trying to avoid using SQL at all:
>>>
>>> Author.where('first_name = ? OR last_name = ?', 'John', 'Smith')
>>>
>>> On Thu, Oct 10, 2019, at 11:52, Vicente Romero Calero wrote:
>>>
>>> Consider the following simple query:
>>>
>>> SELECT * FROM authors WHERE first_name = 'John' OR last_name = 'Smith'
>>>
>>> With ActiveRecord you can write it like this:
>>>
>>> Author.where(first_name: 'John').or(Author.where(last_name: 'Smith'))
>>>
>>> It’s annoying that you need to pass in a whole relation to the `or`
>>> function. It would be nicer to have something shorter and cleaner. So, I
>>> propose to add a `where.or` query method, similar to the existing
>>> `where.not`. This new method would take params in the same way `where`
>>> does, but instead of using AND as a keyword to join the predicates, it
>>> would use OR. The query above would be built as follows:
>>>
>>> Author.where.or(first_name: 'John', last_name: 'Smith')
>>>
>>> I’m not sure if I’m missing something fundamental that makes this
>>> feature difficult to implement. I’ve actually implemented a working version
>>> and I’d be happy to push a PR if the feedback is positive.
>>>
>>> Besides the technical challenges that may arise, do you think it’s a
>>> useful feature?
>>>
>>> Thanks!
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Core" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonrails-core+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-core/125f930d-73ef-4dab-b353-77a8f2e4280a%40googlegroups.com
>>> 
>>> .
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Core" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonrails-core+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-core/3cb23264-3d5a-4b27-b6b4-b541a08e8b99%40www.fastmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> *Kevin D. Deisz*
>> CTO, CultureHQ 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-core+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-core/CALzDYJ0hufhkNgEQvwDYd1nA9LBzrnU_4tWK%2B2KPpd80xi_b9A%40mail.gmail.com
>> 

Re: [Rails-core] [Feature][ActionCable] Possibility from server side to terminate subscription by specifying WebSocket close code and reason

2018-10-05 Thread T.J. Schuck
See also https://github.com/rails/rails/pull/29390 about using proper close
codes for WebSockets.

On Thu, Oct 4, 2018 at 1:45 PM, Artis Abolts  wrote:

> WebSocket.close() method accept two optional parameters:
>
>
>1. code - A numeric value indicating the status code explaining why
>the connection is being closed.
>2. reason - A human-readable string explaining why the connection is
>closing.
>
> More info: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/
> close
>
>
>
>
> Real live example where and how my proposed changes would work in Rails
>
>
>
> For example by terminating subscription from server if User session expired
>
>
> ActionCable.server
>.remote_connections
>.where(current_user: warden_proxy.user)
>.disconnect(4001, "Unauthorized")
>
>
> On JavaScript side possibility to receive WebSocket close code and reason.
> For example if WebSocket closed because User session expired then we
> redirect to root path
>
>
>   disconnected: (data) ->
> # Called when the subscription has been terminated by the server
>
> # If Unauthorized (Session Terminated or Expired)
> if data.statusCode == 4001
>   window.location = "/"
>
>
>
> In Rails ActionCable there is needed only couple changes to support
> WebSocket close code and reason.
>
> Please check my implementation in my Fork: https://github.com/aboltart/
> rails/commit/be168f16118f5848d0d3a9165afeafb6717a71f8
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] [Feature][ActiveSupport::Duration] Use the current locale in .inspect

2018-06-22 Thread T.J. Schuck
Your proposed change wouldn't actually make the change offered up your
example ("hours" to "heures").

The "locale" option here is being passed to `to_sentence` specifically, so
the only thing that would likely change is the word connectors, so "10
years, 1 month *and* 1 day" would end up as "10 years, 1 month *et* 1 day".

You can see this behavior explicitly in the tests added along with the
change to use default_locale in the first place here:
https://github.com/rails/rails/pull/18462/files

On Fri, Jun 22, 2018 at 9:51 AM, Samy Kacimi  wrote:

> Hello,
>
> Currently, the .inspect method of ActiveSupport::Duration handles the
> i18n-ization like this:
>
> def inspect #:nodoc:
>   parts.
> reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
> sort_by {|unit,  _ | [:years, :months, :days, :minutes, 
> :seconds].index(unit)}.
> map {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : 
> unit.to_s}"}.
> to_sentence(locale: ::I18n.default_locale)
> end
>
>
>
> Which can be frustrating if the user's current locale is different from
> the default one.
>
> In my case, a french user would read english versions of inspected
> durations instead of french ones (ie: "12 hours" instead of "12 heures")
>
> What I propose is to change this line of code:
>
> to_sentence(locale: ::I18n.default_locale)
>
>
> To this:
>
> to_sentence(locale: ::I18n.locale)
>
>
> Regards,
> Samy
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] What should be my FAYE_URL value for Rails chat application?

2018-06-19 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Tue, Jun 19, 2018 at 9:19 AM, Malav Desai  wrote:

> I am trying to make a Chat web application based on Rails using
> "private_pub" gem which works perfectly on my localhost server. Now my site
> is hosted on DigitalOcean and i want to push chat code on the server to see
> how real-time chat app will work.
>
> This is my private_pub.yml file
>
>
> development:
>  server: "http://localhost:9292/faye;
>  secret_token: "secret"
> test:
>  server: "http://localhost:9292/faye;
>  secret_token: "secret"
> staging:
>  server: <%= ENV["FAYE_URL"] %>
>  secret_token:"secret_key"
>  signature_expiration: 3600 # one hour
> production:
>  server: <%= ENV["FAYE_URL"] %>
>  secret_token: "secret_key"
>  signature_expiration: 3600 # one hour
>
>
> My question is What should i have to do to make it work on any Linux
> server ( Here Digital Ocean for me). I am using Nginx server on
> DigitalOcean.
>
> What should be the value for FAYE_URL in private_pub.yml file?
>
>
> rackup private_pub.ru -s thin -E production
>
>
> Do i have to run rack command on my server terminal? Or is there any other
> way to host Faye on a different server then?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] [Proposal] define String#json? to return boolean value if the object is json string

2018-04-19 Thread T.J. Schuck
Note that I'm not on the core team, so my answer is far from final, but:
just a heads up that the current refrain on changes to Active Support (and
particularly the core extensions) is roughly "We avoid adding new things to
Active Support unless they are used in the framework or by a large number
of applications, so we need to know why you think this feature is useful to
take any decision" — example
.

You could open a PR with your change to get more discussion since it's a
reasonably minimal and understandable diff, but expect pushback unless you
have a particularly compelling use case. Since this is a core extension
update to String, you could also lobby to have it included in Ruby directly
instead.

On Thu, Apr 19, 2018 at 2:02 AM, Akira  wrote:

> I was looking for a method that return boolean value if the object is json
> string.
> I think there is no support for this idea on 
> activesupport/lib/active_support/core_ext/string
> .
>
> Here is my proposal to include this feature.
>
> activesupport/lib/active_support/core_ext/string/json.rb
>
> class String
>   # An object is json string if it’s parseable by JSON.parse.
>   # return true if it's parseable.
>   # return false if it is not parseable.
>   def json?
> !!JSON.parse(self)
>   rescue
> false
>   end
> end
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Migrations not running in Docker

2018-03-05 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Sat, Mar 3, 2018 at 2:32 PM, Kareem Hepburn  wrote:

> I am having an issue where my migrations are not running in docker. No
> error, no output, nothing.
>
> When I run `rake db:migrate:status` I get this error:
>
> Schema migrations table does not exist yet.
>
>
> But when I run it on the host machine (OSX) migrations run just fine.
>
> Here's my Dockerfile:
>
> FROM scardon/ruby-node-alpine:2.5.0
>
> # install dependencies for nokigiri and postgres
> RUN apk --update add \
> git \
> gcc \
> musl-dev \
> make \
> libxml2 \
> libxslt \
> libxml2-dev \
> libxslt-dev \
> postgresql-client \
> postgresql-dev \
> tzdata
>
> # clean up files
> RUN rm -rf /var/lib/apk/*
>
>
> Any help would be appreciated.
>
> When running in the console, it works just fine.
>
> ActiveRecord::Migrator.migrate "db/migrate"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] ActiveStorage mupdf on heroku?

2018-01-17 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Wed, Jan 17, 2018 at 12:50 PM, Adam Stockland 
wrote:

> I'm struggling with getting mupdf functioning on heroku and wondering if
> anyone can provide some details (I'm assuming Basecamp has it
> functioning...and, I believe they are hosted on Heroku).
>
> I've upgraded to rails 5.2 and am implementing ActiveStorage.  I have
> successfully installed mutool locally using homebrew and everything works
> great.  However, PDFs do not process on Heroku.
>
> mutool is a bit confusing.  Rails docs require "mutool", Homebrew installs
> "mupdf-tools", Heroku wants "mupdf".
>
> I have successfully installed apt and mupdf on heroku following these
> steps:
>
> - add a new Aptfile to the root of my application with only "mupdf"
> listed
> - commit and push the Aptfile
> - THEN run heroku buildpacks:add --index 1 https://github.com/heroku/
> heroku-buildpack-apt
> - push again so heroku will finish installing apt and mupdf
>
> mupdf builds successful during the push
>
> heroku buildpacks now returns
> 1. https://github.com/heroku/heroku-buildpack-apt
> 2. heroku/ruby
>
> If I refresh a page calling for a variant on a PDF, the image fails to
> process and the job kicks back the following error:
>
>   Errno::ENOENT: No such file or directory - mutool
>
> It seems mutool and mupdf are synonomous...so, I tried swapping out mutool
> for mupdf in my Aptfile...that failed to build from "...not found'.
>
> Anyone know what action I need to take?
>
> PS:  This is part of implementing rails 5.2 using ActiveStorage.
>
> # UPDATE
>
> I added mupdf-tools to Aptfile and that seems to fix the "no such file or
> directory" error.  I don't know for sure because a new errors surfaces
>
> MiniMagick::Invalid: `identify /tmp/mini_magick20180105-4-pvub9r`
> failed with error: identify.im6: no decode delegate for this image format
> `/tmp/mini_magick20180105-4-pvub9r' @ error/constitute.c/ReadImage/544.
>
> MiniMagick::Error: `identify -format %m %w %h %b
> /tmp/ActiveStorage20180105-4-1f46tem[0]` failed with error: identify.im6:
> no decode delegate for this image format 
> `/tmp/ActiveStorage20180105-4-1f46tem'
> @ error/constitute.c/ReadImage/544.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Best way to data sync between Rails app and phone

2017-07-21 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Fri, Jul 21, 2017 at 2:09 PM, siva subrahmanyam <
subbu9848155...@gmail.com> wrote:

> Hi
>
> I want build an Rails API which serves as backend for a mobile app. Since
> the mobile app will be used in offline mode. Hence I want data updates
> needs to be synced between mobile and web app. What would be the best
> possible solution for this kind problems?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Redirect to requested page after succesful login

2017-05-18 Thread T.J. Schuck
Hey everyone!

This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

That said, if any of the current participants want to keep helping out
Luis, feel free to keep communicating off-list.

Cheers,
T.J.

On Thu, May 18, 2017 at 11:23 AM, radhames brito  wrote:

> Hi Luis, can you provide a bit more information about the application you
> have, like what gems you are using for authentication?
>
> On Thu, May 18, 2017 at 10:40 AM, Mukesh Singh 
> wrote:
>
>> Hi Luis,
>>
>> *You can use Device gem*
>>
>> *https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
>> *
>>
>> *http://stackoverflow.com/questions/7638920/redirect-after-sign-in-with-devise
>> *
>>
>>
>> *http://stackoverflow.com/questions/15944159/devise-redirect-back-to-the-original-location-after-sign-in-or-sign-up
>> *
>>
>> Thanks,
>> Mukesh
>>
>> On Thu, May 18, 2017 at 7:48 PM, Luis Fernando Naves Santoyo <
>> lfnav...@gmail.com> wrote:
>>
>>> Hi, i have never worked with ruby, but i have a  page that uses it, the
>>> problem is that i want to take a link and send it to other users, so that
>>> when the user clicks it the page detects that it haven't log in and
>>> redirect to the login page, after successful login the login page should
>>> redirect the user to the requested page.
>>> the problem is that it redirecto to the home page after the login
>>> instead the requested page
>>>
>>> this fucntionality is available in ASP.NET and PHP
>>>
>>> the instructions says that new features should be writen by the requeted
>>> user, i don't know where to look to add this feature (lots of files and
>>> lines of code) if someone can give me directions i can try to make an
>>> update, i really don't know pearl but i can try to understand the specific
>>> lines of code
>>>
>>> thanks
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Core" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonrails-core+unsubscr...@googlegroups.com.
>>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/rubyonrails-core.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Regards
>> Mukesh Paras Singh
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-core+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> Visit this group at https://groups.google.com/group/rubyonrails-core.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] has_many through additional (default) attribute values for through record on adding

2016-12-21 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Wed, Dec 21, 2016 at 10:10 AM, Nazar Matus 
wrote:

> For example, I have a User, Achievement and AchievementDate.
> class User < ApplicationRecord
>   has_many :achievement_dates
>   has_many :achievements, through: :achievement_dates
> end
>
> And when I write add an achievement like this:
> user.achievements << achievement
>
> I want through record to be initialized with current date. So I want
> something like this:
> class User < ApplicationRecord
>   has_many :achievement_dates
>   has_many :achievements, through: :achievement_dates, initialize_with: :
> method_name
>
>   private
>
>   def method_name(achievement_date)
> achievement_date.date = Date.current
>   end
> end
>
> Currently I could not find a good way to achieve such behavior in Rails
> 5.0.0.1, so please, give me some advice or feedback.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Why do i need to specify the column type when removing? (migrations)

2016-11-14 Thread T.J. Schuck
Hi Gabriel,

The `type` parameter is actually ignored when removing a column — see the
documentation for `remove_column` here

which
specifies that as well.

The docs also indicate why you might want to include it anyway — if your
migration is implemented using a `change` method instead of `up` and `down`
methods, that parameter indicates what type of column should be added back
if you revert the migration.

Hope that helps,
T.J.

P.S. — This mailing list (rubyonrails-core) is intended for discussion
about development of the framework itself, not usage of it.

For questions like this one that are not issues with Rails itself, please
post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer in the future using one of
those options.

On Mon, Nov 14, 2016 at 1:47 PM, Gabriel Matos <
gabrielmatosdeso...@gmail.com> wrote:

> Hello guys,
>
> I've been using Ruby for a long time now and a simple doubt always make me
> wonder
> Why do i need do specify the column type when removing a column?
>
> I always do the following when removing a column:
>
> remove_column :table, :column, :type
>
> But the thing is...isn't the column name unique? Or can i have multiple
> columns with same name but different types?
>
> Sorry if it's a stupid question tho :P
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Changing URL for devise_token_auth sign_in

2016-06-29 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Wed, Jun 29, 2016 at 8:12 AM, Gokul M  wrote:

> I use *devise_token_auth* and trying to change the users *sign_in* URL. I
> have sessions_controller in my *`api/v2/*` folder and *devise_token_auth* 
> routes
> as below:
>
> *Routes:*
>
> namespace :api do
> namespace :v2 do
> mount_devise_token_auth_for 'User', at: 'users', :controllers => {
>   :registrations => 'api/v2/registrations',
>   :confirmations => 'api/v2/confirmations',
>   :passwords => 'api/v2/passwords',
>   :sessions => 'api/v2/sessions'}
>
>
> post 'users/sign-in', to: 'sessions#create'
> end
> end
>
>
> When I do *rake routes* I get *the route* as I wish:
>
> api_v2_users_sign_in  POST  /api/v2/users/sign-in(.:format)  
> api/v2/sessions#create
>
>
> but, when I try to hit the URL I get the following *error*:
>
> AbstractController::ActionNotFound (Could not find devise mapping for path 
> "/api/v2/users/sign-in".
> This may happen for two reasons:
>
> 1) You forgot to wrap your route inside the scope block. For example:
>
>   devise_scope :user do
> get "/some/route" => "some_devise_controller"
>   end
>
> 2) You are testing a Devise controller bypassing the router.
>If so, you can explicitly tell Devise which mapping to use:
>
>@request.env["devise.mapping"] = Devise.mappings[:user]
>
> ):
>
> 
> /Users/gokul/.rvm/gems/ruby-2.3.0@rails5.0/bundler/gems/devise-bcdd54cc5ebd/app/controllers/devise_controller.rb:88:in
>  `unknown_action!'
> 
> /Users/gokul/.rvm/gems/ruby-2.3.0@rails5.0/bundler/gems/devise-bcdd54cc5ebd/app/controllers/devise_controller.rb:63:in
>  `assert_is_devise_resource!'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:382:in `block 
> in make_lambda'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:169:in `block 
> (2 levels) in halting'
> actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:12:in `block 
> (2 levels) in '
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:170:in `block 
> in halting'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:454:in `block 
> in call'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:454:in `each'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:454:in `call'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:101:in 
> `__run_callbacks__'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:750:in 
> `_run_process_action_callbacks'
> activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:90:in 
> `run_callbacks'
> actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:19:in 
> `process_action'
> actionpack (5.0.0.rc1) lib/action_controller/metal/rescue.rb:31:in 
> `process_action'
> actionpack (5.0.0.rc1) 
> lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
> activesupport (5.0.0.rc1) lib/active_support/notifications.rb:164:in 
> `block in instrument'
> activesupport (5.0.0.rc1) 
> lib/active_support/notifications/instrumenter.rb:21:in `instrument'
> activesupport (5.0.0.rc1) lib/active_support/notifications.rb:164:in 
> `instrument'
> actionpack (5.0.0.rc1) 
> lib/action_controller/metal/instrumentation.rb:30:in `process_action'
> actionpack (5.0.0.rc1) 
> lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
> activerecord (5.0.0.rc1) 
> lib/active_record/railties/controller_runtime.rb:18:in `process_action'
> actionpack (5.0.0.rc1) lib/abstract_controller/base.rb:126:in `process'
> actionpack (5.0.0.rc1) lib/action_controller/metal.rb:190:in `dispatch'
> actionpack (5.0.0.rc1) lib/action_controller/metal.rb:262:in `dispatch'
> actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:50:in 
> `dispatch'
> actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:32:in 
> `serve'
> actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:39:in `block 
> in serve'
> actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:26:in `each'
> actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:26:in `serve'
> actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:725:in 
> `call'
> apipie-rails (0.3.6) 

Re: [Rails-core] Rails edit action getting too big

2016-02-18 Thread T.J. Schuck
This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

On Thu, Feb 18, 2016 at 1:16 AM,  wrote:

> In my current rails application , there are multiple tabs for the edit
> action. All tabs go to the same action. For example if i modify some input
> field in one tab , all the tabs parameters go to edit action.I need to send
> only those modified. Is there any suggestion for this scenario
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] ActiveRecord::Querying#find_by_sql has a confusing interface?

2015-06-25 Thread T.J. Schuck
The `bind` argument was added as `bind_values` all the way back in 2010,
with no change to the documentation:
https://github.com/rails/rails/commit/cc468d3ec81d6f1298fca91c0549584b36dafcc6

So the docs are probably just wrong — I’m sure a documentation PR would be
quickly merged.

On Thu, Jun 25, 2015 at 11:18 AM, James Coleman jtc...@gmail.com wrote:

 Furthermore, the definition of find_by_sql truly is confusing in because
 when used the way the docs say to call it, the binds variable does not
 contain the bind variable. For example:

 irb(main):010:0 def t(x, y=[])
 irb(main):011:1 puts x: #{x.inspect}
 irb(main):012:1 puts y: #{y.inspect}
 irb(main):013:1 end
 = :t
 irb(main):014:0 t(1,2)
 x: 1
 y: 2
 = nil
 irb(main):016:0 t([1,2])
 x: [1, 2]
 y: []

 On Thu, Jun 25, 2015 at 11:06 AM, Nicolás Sanguinetti godf...@gmail.com
 wrote:

  You need to have a deeper understanding of ruby, and specifically the
 magic of the splat (*) operator.

 I think you missed that the method signature is `def find_by_sql(sql,
 binds = [])`, and not `def find_by_sql(sql, *binds)`. There’s no splat in
 the method signature.

 Before trying to belittle someone, maybe make sure that you’re actually
 correct :P

  Remember MINSWAN, people.

 (As for the on-topic conversation, sorry, I have no idea what’s going on
 with that `binds` argument.)

 Cheers,
 -foca




 On Thu, Jun 25, 2015 at 2:38 PM, Matias Korhonen korhonen.m...@gmail.com
  wrote:

 Hi,


 We happened to need #find_by_sql today and noticed that it appears to
 have a somewhat confusing interface/method definition/documentation.

 The method definition is:

  def find_by_sql(sql, binds = [])
   # ...
 end


 Which would seem to imply that you should use it like this:

  Post.find_by_sql(SELECT * FROM posts WHERE id = ?, [1])


 However, that is wrong, you actually need to do (and the examples in the
 documentation are like this):

  Post.find_by_sql([SELECT * FROM posts WHERE id = ?, 1])


 I spent some time reading the documentation and code and can't figure
 out what the binds argument should be used for.

 Maybe some sort of example or explanation should be added to the
 #find_by_sql documentation? I'd do so myself, but I'm having trouble
 figuring it out…


 — Matias

  --
 You received this message because you are subscribed to the Google
 Groups Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] ActiveRecord::Querying#find_by_sql has a confusing interface?

2015-06-25 Thread T.J. Schuck
Sorry, I suppose by “wrong” I meant “incomplete”.

There is a `binds` argument, and it seems to be used, but it is not
documented.

On Thu, Jun 25, 2015 at 11:54 AM, James Coleman jtc...@gmail.com wrote:

 @TJ: No, I don't believe the docs are wrong. If you try the examples they
 only work as documented, and fail if go by what you'd expect from the
 method definition instead.

 On Thu, Jun 25, 2015 at 11:48 AM, T.J. Schuck t...@getharvest.com wrote:

 The `bind` argument was added as `bind_values` all the way back in 2010,
 with no change to the documentation:
 https://github.com/rails/rails/commit/cc468d3ec81d6f1298fca91c0549584b36dafcc6

 So the docs are probably just wrong — I’m sure a documentation PR would
 be quickly merged.

 On Thu, Jun 25, 2015 at 11:18 AM, James Coleman jtc...@gmail.com wrote:

 Furthermore, the definition of find_by_sql truly is confusing in because
 when used the way the docs say to call it, the binds variable does not
 contain the bind variable. For example:

 irb(main):010:0 def t(x, y=[])
 irb(main):011:1 puts x: #{x.inspect}
 irb(main):012:1 puts y: #{y.inspect}
 irb(main):013:1 end
 = :t
 irb(main):014:0 t(1,2)
 x: 1
 y: 2
 = nil
 irb(main):016:0 t([1,2])
 x: [1, 2]
 y: []

 On Thu, Jun 25, 2015 at 11:06 AM, Nicolás Sanguinetti godf...@gmail.com
  wrote:

  You need to have a deeper understanding of ruby, and specifically the
 magic of the splat (*) operator.

 I think you missed that the method signature is `def find_by_sql(sql,
 binds = [])`, and not `def find_by_sql(sql, *binds)`. There’s no splat in
 the method signature.

 Before trying to belittle someone, maybe make sure that you’re actually
 correct :P

  Remember MINSWAN, people.

 (As for the on-topic conversation, sorry, I have no idea what’s going
 on with that `binds` argument.)

 Cheers,
 -foca




 On Thu, Jun 25, 2015 at 2:38 PM, Matias Korhonen 
 korhonen.m...@gmail.com wrote:

 Hi,


 We happened to need #find_by_sql today and noticed that it appears to
 have a somewhat confusing interface/method definition/documentation.

 The method definition is:

  def find_by_sql(sql, binds = [])
   # ...
 end


 Which would seem to imply that you should use it like this:

  Post.find_by_sql(SELECT * FROM posts WHERE id = ?, [1])


 However, that is wrong, you actually need to do (and the examples in
 the documentation are like this):

  Post.find_by_sql([SELECT * FROM posts WHERE id = ?, 1])


 I spent some time reading the documentation and code and can't figure
 out what the binds argument should be used for.

 Maybe some sort of example or explanation should be added to the
 #find_by_sql documentation? I'd do so myself, but I'm having trouble
 figuring it out…


 — Matias

  --
 You received this message because you are subscribed to the Google
 Groups Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com
 .
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google
 Groups Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google
 Groups Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you

Re: [Rails-core] Mailers --Need Help

2014-11-11 Thread T.J. Schuck
Hi Nicole,

This mailing list (rubyonrails-core) is intended for discussion about
development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues
with Rails itself, please post to the rubyonrails-talk mailing list (
http://groups.google.com/group/rubyonrails-talk) or somewhere like
StackOverflow using the `ruby-on-rails` tag (
http://stackoverflow.com/questions/tagged/ruby-on-rails).  You can also
drop in to the #rubyonrails channel on irc.freenode.net for realtime help.
You'll be more likely to get a quick answer using one of those options.

-T.J.

On Tue, Nov 11, 2014 at 8:34 AM, Nicole Morales nmorale...@gmail.com
wrote:

 Hi all

 Im pretty new to Ruby on Rails.  My boss created an app and is asking me
 to create a worker to email us when there is a conflict of events for a DJ.
 It works in the terminal but Im having problems getting the event details
 of the conflict to display in my mailer.  Im trying to test it out with
 mail catcher to see if Im doing it correctly but I do not know what to pass
 for the overlaps parameter in my test.  Below is my code. Can someone help
 me out?

 My worker says this(PLEASE LOOK AT THE CAPS)

 *class TalentConflictsWorker*
 *include Sidekiq::Worker*
 *include Sidetiq::Schedulable*
 *sidekiq_options retry: false*

 *MAX_CALENDARS_TO_SCHEDULE_AT_ONCE=10*


 *def perform (user_id)*

 *user=User.find(user_id)*
 *events=user.calendar.events*
 *events.each do |e|*
 #Checking for conflicting events. If not the same event and
 has an overlap, display name and start date.
  *   overlaps=events.where((strftime('%s',start) -
 strftime('%s',?)) * (strftime('%s',?) - strftime('%s',end)) = 0 ,
 e.start, e.end ).where.not(id: e.id http://e.id)*
 *overlapsflag=overlaps.present?*
 #overlaps=where((start,events.end) OVERLAPS (timestamp ?,
 timestamp ?) AND not(id: e.id).present?

  *   if overlapsflag*

 *CalendarMailer.talent_conflict(user, events,
 overlaps).deliver*

 *#FOR TERMINAL ---THIS WORKS IN THE TERMINAL (when
 uncommented) MY ISSUE IS HOW DO I PASS THE OVERLAPS AND GET THOSE EVENTS TO
 DISPLAY IN THE EMAIL*
 #puts Conflict found, e.name, e.start
 #overlaps.each do |overlap_event|
 #puts overlap_event.name
 #puts overlap_event.start
 #overlapstring=overlap_event.to_s
 #end
 #else
 #puts NO EVENT CONFLICT FOUND
   *  end   *
 *end   *
 *end*
 *end*

 *Heres the mailer I THOUGHT PERHAPS I PUT THE DO LOOP IN THE MAILER? *

 *def talent_conflict(user, events, overlaps)*
 *@user=user*
 *@events=events*
 *@overlaps= overlaps*
 *overlaps.each do |overlap_event|*
 *puts overlap_event.name http://overlap_event.name*
 *puts overlap_event.start*
 *#overlapstring=overlap_event.to_s*
 *end*
 *mail(subject: SMG Talent: detected an event conflict ))*
 *end*

 *THIS IS THE HTML *

 *pEvent conflicts have been detected./p*

 *ul*

 *li%= @events.name http://events.name % held on %= @events.start %
 conflicts with the following event: %= @overlaps.name
 http://overlaps.name %%= @overlaps.start %/li*


 */ul*

  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] ObjectSpace#allocation_class_path not working as expected.

2014-06-12 Thread T.J. Schuck
This mailing list is specific to the development and design of Rails.

ObjectSpace is a library in Ruby itself and has nothing in particular to do
with Rails.  Consider posting to one of the Ruby mailing lists instead:
https://www.ruby-lang.org/en/community/mailing-lists/


On Thu, Jun 12, 2014 at 6:07 AM, Rajeev Bharshetty rbharshe...@gmail.com
wrote:

 Using Ruby Version 2.1.2


 class A
   def foo
 ObjectSpace::trace_object_allocations do
   obj = Object.new
   p #{ObjectSpace::allocation_class_path(obj)}
 end
   endend
 A.new.foo #= Class

 The above method is expected to return back the allocation class path of
 the object.
 But I am getting an empty string back instead of Class.
 Is it an implementation bug in the method or the documentation is not
 updated.


 Thanks

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] About pool management in ActiveRecord

2014-05-30 Thread T.J. Schuck
Specifically regarding a Thread outside of the main request thread holding
onto a connection, you might be interested in
https://github.com/rails/rails/pull/14360 about more intelligently reaping
connections held onto by dead threads.

Unfortunately, the comments on that PR say it will not be backported to 4.1
and will only be included in 4.2  :(


On Fri, May 30, 2014 at 9:10 AM, Rodrigo Rosenfeld Rosas rr.ro...@gmail.com
 wrote:

  Yesterday someone commented in my article on Sequel, where I compare it
 with AR in some aspects, including pool management:


 http://rosenfeld.herokuapp.com/en/articles/ruby-rails/2013-12-18-sequel-is-awesome-and-much-better-than-activerecord

 To answer his comments I decided to first take a glance at the current
 (4.1.1) implementation of how the connections' pool work in Rails with AR.

 After our discussion in the comments, when I was about to sleep, I was
 thinking more about this subject and decided it might worth bringing some
 ideas to you, in case you'd be interested on them...

 Basically, ActiveRecord currently relies on delegating the connection pool
 management to the user. Most users don't realize it because they don't
 usually spawn new threads from the main request thread and there's an AR
 middleware that's automatically integrated to Rails that will checkin the
 connection back to the pool in the end of the request. Since the connection
 id is set in a thread local that means the Rack middleware can only checkin
 the connection used in the main request thread. Here's some example to
 illustrate:

 class MainController  def indexThread.start{ Post.count }head :ok  
 endend


 Assuming the default pool size (5), running this action 6 times will fail
 currently:

 ab -n 6 -c 1 http://localhost:3000/main/index

 This is not anything new and Aaron Patterson has already touched this
 subject long ago, in 2011:


 http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord.html

 In a side note, yesterday I learned about an interesting project to set a
 common API for job libraries that is intended to be merged to Rails at some
 point:

 https://github.com/rails/activejob

 The default adapter (inline) implements an enqueue_at method that will
 spawn a new thread:


 https://github.com/rails/activejob/blob/master/lib/active_job/queue_adapters/inline_adapter.rb#L9-L18

 So, calling enqueue_at for a job using the default adapter will share the
 same problems of the implementation above.

 Then I was thinking that most of AR API could be implemented in a smarter
 way, so that this wouldn't be a problem. That means calling
 with_connection behind the scenes whenever they need a connection.

 Also, even execute could be implemented this way. Instead of checking
 out a connection by calling AR::Base.connection, it could simply return a
 proxy. If you really want to checkout and reserve that connection you could
 call connection.lock for instance and then the user would know that they
 must ensure unlock is called after it's done. But otherwise, calling
 execute would perform the query under a with_connection block, checking
 the connection in back to the pool after running the SQL statement.

 I'm just suggesting the idea in case someone might be interested in coming
 up with a PoC for this in case the core team agrees with the suggested
 approach (it introduces a bit of backward incompatibilities). I don't plan
 to work on this, specially because I don't use AR myself, but maybe a
 better automatic handling of connections in the pool might be of interest
 to most AR users...

 Cheers,
 Rodrigo.

  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Enum, ActiveModel and I18n

2014-04-14 Thread T.J. Schuck
 Why not put Enum into ActiveModel? We may need some enumeration into
another model without ActiveRecord, a example: something like a mail object
form with a enumeration for subject…

If the object isn’t persisted to the DB, it doesn’t seem like you’d need to
use AR::Enum — the primary benefit is that it maps the options to integers
in the DB column.  For a non-persisted model, you can just use a regular
attribute with an inclusion validation like Rafael mentioned.

 By what you described I believe you can reach with validates_inclusion_of and
a hash.

Note that AR::Enum doesn’t play nicely with `inclusion` validations — see
https://github.com/rails/rails/issues/13971 — so this only applies to the
provided workaround for a  non-persisted object.



On Mon, Apr 14, 2014 at 4:29 PM, Rafael Mendonça França 
rafaelmfra...@gmail.com wrote:

 Hi,

 Could you explain a bit more about the use case you are thinking for enum
 feature on Active Model?

 By what you described I believe you can reach with validates_inclusion_ofand 
 a hash. An example of the controller and view would help.

 Also, could you also explain what is the use case for i18n for enum values?

 Rafael Mendonça França
 http://twitter.com/rafaelfranca
 https://github.com/rafaelfranca


 On Mon, Apr 14, 2014 at 4:25 PM, Sadjow Leão sad...@gmail.com wrote:

 Hi folks,

 I'm thinking about a Pull Request for Rails. But, I want to validate with
 you.

 Why not put Enum into ActiveModel? We may need some enumeration into
 another model without ActiveRecord, a example: something like a mail object
 form with a enumeration for subject... and other situations.

 And a second Pull Request is:

 i18n for enum values. We need that.

 What do you think about?

 Thanks,

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] single quotes for controller generated routes

2014-01-13 Thread T.J. Schuck
I don’t think this justifies one over the other.  First of all, on my
machine, the “winning” version flip flops pretty consistently — each one
wins about 50% of the time.

Secondly, a half a second of performance difference over 50 *million*
iterations
doesn’t quite feel conclusive that one is inherently more “performant”.

I’m +1 on making the styles match between the default example routes and
the generated routes.


On Mon, Jan 13, 2014 at 6:20 PM, Steve Klabnik st...@steveklabnik.comwrote:

 action@emmag-55474:~$ cat quotes.rb
 require 'benchmark'

 n = 50_000_000
 Benchmark.bm do |x|
   x.report(single) { n.times { 'I am a single quote' } }
   x.report('double') { n.times { I am a double quote }}
 end
 action@emmag-55474:~$ ruby quotes.rb
user system  totalreal
 single  7.53   0.01   7.54 ( 14.913394)
 double  7.15   0.04   7.19 ( 14.202322)

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails-core] Setup of rails repo for contribution and existing failing tests

2013-08-16 Thread T.J. Schuck
Additionally, use the rails-dev-box for running the tests -- it's a
standardized environment with all necessary dependencies installed:
https://github.com/rails/rails-dev-box


On Fri, Aug 16, 2013 at 12:27 PM, richard schneeman 
richard.schnee...@gmail.com wrote:

 If you have failing tests locally but they are passing on Travis make sure
 your master branch is at the same commit of the one Travis ran against.
 Sometimes failures do get pushed to master, though they're (hopefully)
 fixed quickly, and you may have forked or cloned while master was actually
 failing. I like adding an `upstream` remote to my git config `git config
 -e` so I can quickly grab the latest from rails/rails master  `git pull
 --rebase upstream master`.

 All tests should be passing, make sure you haven't accidentally added
 anything to the files, also make sure to always run tests with `bundle
 exec`. After that it may be something setup with your environment, maybe
 try re-installing rubies, and/or ruby gems. Try it on a friends or
 co-workers computer to see if you get a failure there, then try to figure
 out the differences in environment.

 Worst case scenario if you cannot get that one single test passing and you
 want to contribute first run the tests against unchanged master (as you
 already did) and make note of failing tests. Then make your change in a
  branch, and re-run tests. If no additional tests fail it is likely safe to
 make a PR. Pull requests get tested against travis, so you will see if it
 fails on CI.

 Happy bug fixing,
 Richard Schneeman
 @schneems



 On Fri, Aug 16, 2013 at 5:39 AM, Pawel Janiak brand.magn...@gmail.comwrote:

 I have 2  questions for anyone that contributes to Rails.


1. How have you setup your bash output to have colors when running
the full test suite for easy parsing of red/green/yellow of the suite?
2. If you run the suite and there are failing tests, is that expected
from time to time? https://travis-ci.org/rails/rails shows a green
build but in this instance I get a failure on:

*actionpack/test/controller/render_test.rb:1465*

 Thanks

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails-core] Date.weekend?

2013-06-28 Thread T.J. Schuck
This introduces a localization issue -- not everyone has a Saturday/Sunday
weekend!  Particularly Islamic countries:
http://en.wikipedia.org/wiki/Workweek_and_weekend#Islamic_countries but
also Israel, Nepal, India, and others.




On Thu, Jun 27, 2013 at 12:16 PM, Artem Kalinchuk art...@gmail.com wrote:

 Hello,

 Having a boolean *.weekend?* on the Date class would be a good feature.
 It will basically do this:

 saturday? || sunday?

 Makes the code cleaner and easier to read.

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails-core] How should ActiveSupport::Cache handle nil cache key?

2013-06-25 Thread T.J. Schuck
From the table in your pull request, the MemCacheStore seems to be the one
I'd expect from all the options, i.e. writing or reading a nil key raises
ArgumentError: key cannot be blank.

Considering the docs even go as far as to say MemCacheStore is currently
the most popular cache store for production websites and its current
implementation is the most breaking, I think it makes sense to mirror its
behavior for the more dev environment oriented options.


On Sat, Jun 22, 2013 at 4:28 AM, Huiming Teo teohuim...@gmail.com wrote:

 Hi, I notice ActiveSupport::Cache implementations behave differently when
 cache key is nil.

 cache_key = nil
 Rails.cache.write(cache_key, 'value')
 Rails.cache.read(cache_key)

 For example, FileStore raises a file system error No such file or
 directory when calling write() with nil cache key. This error does not
 communicate what actually went wrong (i.e. cache key cannot be
 nil/empty). It's better if a descriptive exception is raised.
 Anyway, I'm curious what should be the expected behavior when cache key
 is nil? And whether the expected behavior should be specified in
 ActiveSupport::Cache or in its implementation?

 fyi, more details and failing tests are available:
 https://github.com/rails/rails/pull/11009

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.