[Rails] Same custom method validation with different fields of same type

2015-10-28 Thread Rodrigo Lueneberg
How can I refactor this coordinate validation routine so that I can use this method with other fields of the same type, for instance, with "full_last_position" and also maintain the cleanliness of the code and avoiding repeating method code? class Provider < ActiveRecord::Base include UtilsModul

[Rails] Re: Re: Rails PostgreSQL wrong decimal to numeric convertion after migration

2015-01-28 Thread Rodrigo Lueneberg
Thank. DonĀ“t need to say anything else. Indeed it is not rails fault. PostgreSQL 9.3.5 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit Hassan Schroeder wrote in post #1167348: > On Wed, Jan 28, 2015 at 8:27 AM, Rodrigo Lueneberg > wrote: >>

[Rails] Re: Rails PostgreSQL wrong decimal to numeric convertion after migration

2015-01-28 Thread Rodrigo Lueneberg
OK, but if they are the same there would be no need for 2 different types under PostgreSQL database. According to the post link provided, decimal is more flexible allowing to store less decimal as opposed to numeric which requires all decimal places to be filled in. This means that using decima

[Rails] Rails PostgreSQL wrong decimal to numeric convertion after migration

2015-01-28 Thread Rodrigo Lueneberg
After running a migration I noticed that rails is changing the specified decimal data type in PostgreSQL. Is there a reason for that? According to this post: http://stackoverflow.com/questions/1841915/difference-betweeen-decimal-and-numeric I found that there is a slight difference between decimal

[Rails] Re: after_validation stack level too deep

2014-06-18 Thread Rodrigo Lueneberg
Thank you. It was typo, fixed now. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr..

[Rails] Re: after_validation stack level too deep

2014-06-18 Thread Rodrigo Lueneberg
Walter, thanks for pointing this out. I think this is the problem, let me check and I will get back. Thank you Walter Davis wrote in post #1150092: > On Jun 18, 2014, at 2:09 PM, Walter Lee Davis wrote: > >>> >>> validates :state, presence: true >>>self.city = populate_address.city >>>s

[Rails] after_validation stack level too deep

2014-06-18 Thread Rodrigo Lueneberg
I am experiencing a loop within a after_validation when trying to update some attributes. Looks like it is calling validation recursively again and again and I am getting "stack level too deep" error message. I tried using a skip_callbacks but with no success. Why is this occurring and how to fix

[Rails] Re: Relation count returns syntax error in Rails 4.1.X

2014-06-01 Thread Rodrigo Lueneberg
By the way what would be more efficient, count(:all) or count(1)? thanks Rod -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, sen

[Rails] Re: Relation count returns syntax error in Rails 4.1.X

2014-06-01 Thread Rodrigo Lueneberg
Thanks, I am glad we are on the same page. Sorry, I did not see your github post. I will check that right now. Rod -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group

[Rails] Re: Re: Relation count returns syntax error in Rails 4.1.X

2014-06-01 Thread Rodrigo Lueneberg
t using raw SQL, don't you agree? Rod josh.jor...@gmail.com wrote in post #1148444: > If you're calling count, it doesn't matter what select values you've > passed, since you're asking ActiveRecord to return an aggregate, not any > column values. > > > On S

[Rails] Re: Relation count returns syntax error in Rails 4.1.X

2014-06-01 Thread Rodrigo Lueneberg
Josh, If I remove the call to "select" how to specify which columns to select? PS: You don't want Rails to select all using wildcard * as it will affect performance. Thanks Rod -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Gro

[Rails] Re: jquery_ujs.js 404

2014-05-31 Thread Rodrigo Lueneberg
thank you Mike. Good that you pointed out railstutorial.org. I just checked and Michael Hartl has updated the Learn Rails by Example to version 4. There is a free version here to read online: http://www.railstutorial.org/book/beginning -- Posted via http://www.ruby-forum.com/. -- You receive

[Rails] Relation count returns syntax error in Rails 4.1.X

2014-05-31 Thread Rodrigo Lueneberg
Until Rails 4.0.4 everything was working fine until I upgraded to latest Rails version. It seems to be a bug because from the error message looks like rails is doing just a count(Bla bla )without using properly using a select count(id) from (SELECT COUNT(orders_header.id, orders_header.created_at)

[Rails] Re: jquery_ujs.js 404

2014-04-28 Thread Rodrigo Lueneberg
Thank you very much, It looks like you're right. All these problems began to occur after I moved the app to production using passenger/nginx. I used google version because that was the last version. I did not know this was being included twice by jquery_ujs.js. In fact, I was able get rid of so

[Rails] Re: jquery_ujs.js 404

2014-04-27 Thread Rodrigo Lueneberg
Thanks for looking at it. There goes the home controller bellow. And yes I am using gem 'jquery-rails'. What is funny is that in my development environment locally it is working. This error is from an passenger/nginx installation. Rod class HomeController < ApplicationController layout 'home'

[Rails] jquery_ujs.js 404

2014-04-25 Thread Rodrigo Lueneberg
I am getting this annoying error which relates to jquery_ujs.js not being served. Any clues? This is the site link: http://test.kopy.com.br/home/index GET http://test.kopy.com.br/assets/jquery_ujs.js?body=1 404 (Not Found) index:11 GET http://ads.panoramtech.net/loader.js?client=tac net::ERR_BLOC

[Rails] Re: Rails 4.1 activerecord_relation conversion to array problem

2014-04-17 Thread Rodrigo Lueneberg
Thanks Walter, I did not know about this gem. Walter Davis wrote in post #1143372: > I believe Kaminari can be dropped in (uses the same verbs) and it might > work for you. (Last commit was 7 days ago, if that means anything.) > > Walter -- Posted via http://www.ruby-forum.com/. -- You receive

[Rails] Re: Rails 4.1 activerecord_relation conversion to array problem

2014-04-17 Thread Rodrigo Lueneberg
Thanks, I did updated will_paginate gem and still the problem. Looks like it is not compatible with rails 4.1 The last version is of 3.0.5 September 18, 2013 (34 KB) according to the link below: https://rubygems.org/gems/will_paginate/versionsOn However, on rails 4.0.4 it works beautifully. Ro

[Rails] Rails 4.1 activerecord_relation conversion to array problem

2014-04-10 Thread Rodrigo Lueneberg
After I upgraded from rails 3.2 to 4.1 I am getting this error below. I researched that Rails 4.1 requires a conversion of an activerecord_relation to an array using to_a. I did use to_a but looks like rails is doing a select count behind the scenes. Do you know how to fix this? def index

[Rails] Re: Rails shared helpers within views conflict

2014-02-08 Thread Rodrigo Lueneberg
There it goes the example. Sorry, I did not know how to format. def self.get_order_assets(od_id) return OrderAsset.select("assets.file_name, order_assets.*").joins("INNER JOIN assets ON assets.id = order_assets.asset_id ").where("order_detail_id=#{od_id}") end def get_order_assets(od_id)

[Rails] Re: Rails shared helpers within views conflict

2014-02-06 Thread Rodrigo Lueneberg
I got it. There is also another way, which is to define the helper method as an instance of the helper class using "self". This way: def self.format_currency(price) ... end Then in the view this this <%= Admin::currencyHelper.format_currency(price)%> But the drawback is that you have to manual

[Rails] Re: Rails shared helpers within views conflict

2014-02-05 Thread Rodrigo Lueneberg
Frederick Could you please elaborate "helper :currency?" Can you give an example? Thanks Rod Frederick Cheung wrote in post #1135734: > On Wednesday, February 5, 2014 7:29:41 PM UTC, Ruby-Forum.com User > wrote: >> >> Frederick, >> >> Thanks. I am glad you agree with me. By the way, do you recom

[Rails] Re: Rails shared helpers within views conflict

2014-02-05 Thread Rodrigo Lueneberg
Frederick, Thanks. I am glad you agree with me. By the way, do you recommend setting this option to false as good practice on every fresh project? Looks like your idea solves the issue, but of course, will force you to dump stuff like you said, in application.rb. I researched a little bit and

[Rails] Rails shared helpers within views conflict

2014-02-05 Thread Rodrigo Lueneberg
According to this article Rails helpers from all controllers are available to all views. But to me this looks kind of a dangerous approach because I might at some point use helper methods with the same name but with different implementations that can cause conflicts and undesired results. This actu

[Rails] grouped_collection_select collection filter

2013-10-20 Thread Rodrigo Lueneberg
I am having a hard time to alter the where condition of the grouped_collection_select collection: Country.where("name='Brazil'") not to use hard coded value, but the form value. This is how it is working: <%= f.grouped_collection_select(:state, Country.where("name='Brazil'").order(:name), :states,

[Rails] Automatic route match for home and admin

2013-10-16 Thread Rodrigo Lueneberg
I am trying to avoid having to type each controller path manually and use the match as in here: ':controller(/:action(/:id))(.:format)'. So I commented out all the manually routes and uncommented the match rule down at the bottom of routes.rb. It works for home controllers, but not the ones locat

[Rails] Re: URL "id" not part of the params objects after post

2013-07-05 Thread Rodrigo Lueneberg
Sorry, I just come from .net and I am used to Request.Querystring[] which is able to fetch any URL parameter on post. The Request object, in this case, takes care storing the URL parameter values. One other idea you just gave me is to create an input field which would obtain the value from the

[Rails] Re: URL "id" not part of the params objects after post

2013-07-05 Thread Rodrigo Lueneberg
Thanks Robert, You just gave some insight. You're right I should use form_for, but I just want to point that the user id is indeed passed in the URL above. But I don't understand why it is not part of the "request" object querystring parameters? Any Framework should be able to capture both pos

[Rails] URL "id" not part of the params objects after post

2013-07-05 Thread Rodrigo Lueneberg
Why is the URL "id" element not part of the params objects after submitting a form via form_tag? Steps: 1. Go to URL http://localhost:3000/users/delete?id=45 2. Press Submit button 3. Read id param in order to delete user, then redirect form Delete Confirmation <%= form_tag('/users/delete') do %