[Rails-core] [ANN] Rails version 3.2.5 has been released!

2012-05-31 Thread Aaron Patterson
Good news everyone! Rails version 3.2.5 has been released. This version of Rails is a less broken version of 3.2.4! ## What happened with 3.2.4? A regression was reported in the release candidate. I reverted that regression without releasing another release candidate for testing. This release

Re: [Rails-core] Route helpers in JS/CS assets

2012-05-31 Thread Steve Schwartz
You're right, I searched my bookmarks for "js rails routes" and that came up, my bad. There is another project that also does this, which was on Hacker News a while back I think, but I can't remember what it's called. -- Steve Schwartz On Thursday, May 31, 2012 at 4:38 PM, Rodrigo Rosenfeld Ro

Re: [Rails-core] Route helpers in JS/CS assets

2012-05-31 Thread Rodrigo Rosenfeld Rosas
This only works in Rails console. Not in ERB views. Steve, while crossroads.js is unrelated to this request, thank you very much for pointing me out js-routes. I'll give it a try soon. Cheers, Rodrigo. Em 31-05-2012 17:33, Pedro Nascimento escreveu: Try `app.root_path`. On Thu, May 31, 201

Re: [Rails-core] Route helpers in JS/CS assets

2012-05-31 Thread Pedro Nascimento
Try `app.root_path`. On Thu, May 31, 2012 at 5:19 PM, Rodrigo Rosenfeld Rosas wrote: > Em 31-05-2012 17:11, Steve Schwartz escreveu: > > There are a couple gems and projects that do this: > > * https://github.com/railsware/js-routes > * http://millermedeiros.github.com/crossroads.js/ > > I th

Re: [Rails-core] Route helpers in JS/CS assets

2012-05-31 Thread Rodrigo Rosenfeld Rosas
Em 31-05-2012 17:11, Steve Schwartz escreveu: There are a couple gems and projects that do this: * https://github.com/railsware/js-routes * http://millermedeiros.github.com/crossroads.js/ I think this is likely outside the scope of rails core, given that most people doing ajax requests will be

Re: [Rails-core] Route helpers in JS/CS assets

2012-05-31 Thread Steve Schwartz
There are a couple gems and projects that do this: * https://github.com/railsware/js-routes * http://millermedeiros.github.com/crossroads.js/ I think this is likely outside the scope of rails core, given that most people doing ajax requests will be using the jquery-ujs or prototype-ujs helpers.

[Rails-core] [ANN] Rails version 3.2.4 has been released!

2012-05-31 Thread Aaron Patterson
Good news everyone! Rails version 3.2.4 has been released. This release of Rails contains two important security fixes: * CVE-2012-2660 Ruby on Rails Active Record Unsafe Query Generation Risk * CVE-2012-2661 Ruby on Rails Active Record SQL Injection Vulnerability It is suggested that all u

[Rails-core] [ANN] Rails version 3.1.5 has been released!

2012-05-31 Thread Aaron Patterson
Good news everyone! Rails version 3.1.5 has been released. This release of Rails contains two important security fixes: * CVE-2012-2660 Ruby on Rails Active Record Unsafe Query Generation Risk * CVE-2012-2661 Ruby on Rails Active Record SQL Injection Vulnerability It is suggested that all u

[Rails-core] [ANN] Rails version 3.0.13 has been released!

2012-05-31 Thread Aaron Patterson
Good news everyone! Rails version 3.0.13 has been released. This release of Rails contains two important security fixes: * CVE-2012-2660 Ruby on Rails Active Record Unsafe Query Generation Risk * CVE-2012-2661 Ruby on Rails Active Record SQL Injection Vulnerability It is suggested that all

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread James B. Byrne
On Thu, May 31, 2012 09:23, Sam Oliver wrote: > On Thu, May 31, 2012 at 2:12 PM, James B. Byrne > wrote: > >> >> > I would generate attribute query methods only for boolean >> attributes. >> >> I am not sure that I understand your point, but in Ruby anything >> that >> is neither nil nor false is

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Allen Madsen
Maybe it is just me, but I don't use features that I don't like in rails, just like I avoid calling private methods. In that sense, there's nothing that is preventing anyone from using `post.body.present?` instead of `post.body?`. My argument would be to let rational programmers decide what is best

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Maksym Melnychok
On Thursday, May 31, 2012 4:50:05 PM UTC+2, Steve Klabnik wrote: > > It's not saving a character. It's that !! is programmer talk, and ? is > human talk. Ruby prefers human talk. > well your kung-fu beats my kung-fu here i just don't think post.url? is talking proper human talk to me, i would

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rodrigo Rosenfeld Rosas
Another way would add another annotation method to ActiveRecord::Base, like: boolean_field :incomplete, :disabled, :deleted This would further document the model mapping and would also allow better semantics. Not that I really care about this as I don't even use ActiveRecord ;) Cheers, Rodri

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rafael Mendonça França
And in these cases you don't know if these fields are boolean or not. If you are choose to store the visible column as string ["yes", "no] so you will not have the query method. I like this method as it is. For me it is very useful and give me the possibility to not care about what is the datatype

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rodrigo Rosenfeld Rosas
Em 31-05-2012 11:52, Rodrigo Rosenfeld Rosas escreveu: Em 31-05-2012 11:48, Maksym Melnychok escreveu: @ Rafael Mendonça França legacy databases storage must be concern of corresponding database adapter, if a field is of boolean type, whatever that means on storage level of particular database,

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rodrigo Rosenfeld Rosas
Em 31-05-2012 11:48, Maksym Melnychok escreveu: @ Rafael Mendonça França legacy databases storage must be concern of corresponding database adapter, if a field is of boolean type, whatever that means on storage level of particular database, that field must be treated as boolean in rails on the

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Steve Klabnik
> but if we decide that there doesn't have to be semantical contribution to > your code from using attribute query methods then #{attribute}? is just > a shortcut for !!#{attribute} - so why do we need it in the first place? > saving 1 character is weird goal here. It's not saving a character. It'

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Maksym Melnychok
@ Rafael Mendonça França legacy databases storage must be concern of corresponding database adapter, if a field is of boolean type, whatever that means on storage level of particular database, that field must be treated as boolean in rails on the model level. i'm not suggesting to drop such fun

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rodrigo Rosenfeld Rosas
Em 31-05-2012 11:30, Rafael Mendonça França escreveu: Actually the query attribute method does more than check if the value is present. It is very useful for legacy databases where the user persist boolean values as [0, 1], ["t", "f"], ["true", "false"] and more. I don't see this being removed

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rafael Mendonça França
Actually the query attribute method does more than check if the value is present. It is very useful for legacy databases where the user persist boolean values as [0, 1], ["t", "f"], ["true", "false"] and more. I don't see this being removed from rails or changing your behavior. Also removing it w

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Steve Klabnik
Not using is_ is idiomatic: http://devblog.avdi.org/2011/04/07/rspec-is-for-the-literate/ (look for 'There is a different, but related, effect of using RSpec.') Every Ruby object is truthy or falsey, and so treating them all as possibly boolean is 100% okay as far as I'm concerned. -- You receiv

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Rodrigo Rosenfeld Rosas
I'd guess methods count is relevant based on this pull request: https://github.com/rails/rails/pull/5763 Em 31-05-2012 10:49, Maksym Melnychok escreveu: absolutely agree with all points. i just didn't know if methods count argument is relevant at all. imo it's a nice side-effect of proposed cha

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Maksym Melnychok
absolutely agree with all points. i just didn't know if methods count argument is relevant at all. imo it's a nice side-effect of proposed change. On Thursday, May 31, 2012 3:45:23 PM UTC+2, richard schneeman wrote: > > I'm -1 on a has_* method > > If we want to kill ? on non boolean attributes we

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Jarrett Meyer
+1 to Richard. Keep ? for booleans, get rid of the others and use .blank? and .present? as needed. -- Jarrett Meyer Email: jarrettme...@gmail.com Web: JarrettMeyer.com Twitter: @jarrettmeyer On Thu, May 31, 2012 at 9:45 AM, Richard Schn

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Richard Schneeman
I'm -1 on a has_* method If we want to kill ? on non boolean attributes we should encourage standard @post.url.blank? and @post.url.present? be used instead. The originally proposed change makes sense to me. The question mark character adds nice semantics to boolean attributes. I agree it's not

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Jeremy Walker
On 31 May 2012 14:23, Sam Oliver wrote: > On Thu, May 31, 2012 at 2:12 PM, James B. Byrne wrote: > >> >> > I would generate attribute query methods only for boolean attributes. >> >> I am not sure that I understand your point, but in Ruby anything that >> is neither nil nor false is true. Thus r

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Sam Oliver
On Thu, May 31, 2012 at 2:12 PM, James B. Byrne wrote: > > > I would generate attribute query methods only for boolean attributes. > > I am not sure that I understand your point, but in Ruby anything that > is neither nil nor false is true. Thus returning the url string, if > not nil, is the same

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread Maksym Melnychok
my point is about semantics, not truthiness/falseness of values post.visible? - is asking post object if it is visible because it has a flag(boolean attribute) named 'visible' post.url? - is checking if attribute named 'url' is present or not, and that is exactly what i find confusing because eve

Re: [Rails-core] Attribute query methods and semantics

2012-05-31 Thread James B. Byrne
On Thu, May 31, 2012 08:58, Maksym Melnychok wrote: > Does anyone else finds attribute query methods semantically confusing? > > Hi, > > Consider this code: > > post = Post.new(:visible => true, :url => "http://com";) > > if post.visible? > puts "ima visible!" > end > > if post.url? > puts "im

[Rails-core] Route helpers in JS/CS assets

2012-05-31 Thread Rodrigo Rosenfeld Rosas
Are there any reasons why Rails doesn't have any route helpers available for the JS/CS assets? We're doing more and more client-side code and it is very likely that you'll need to do something like "$.post products_path, params" somewhere in your code. Currently for doing that you'd need to

[Rails-core] Attribute query methods and semantics

2012-05-31 Thread Maksym Melnychok
Does anyone else finds attribute query methods semantically confusing? Hi, Consider this code: post = Post.new(:visible => true, :url => "http://com";) if post.visible? puts "ima visible!" end if post.url? puts "ima url! (wait wat? o_0)" end Does this feel right to you? In case with post.