[Rails] Re: Why RoR over PHP Framework ?

2012-02-21 Thread Robert Walker
Raimon Fs wrote in post #1047948: Robert Walker wrote in post #1047899: Raimon Fs wrote in post #1047848: - Is it true that a slow queriy on RoR lock all other concurrent connections? This was true on old RoR versions. This could be true in many cases, but is this really different from PHP?

Re: [Rails] encoding special characters in ror

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 11:23, sachin kewale wrote: hi all, i have one problem while encoding the special characters like '',./?:!@#$%^*():;\{}[] ,I get string of book name containing some special characters, now i have to replace those characters with encoded value so i write following

Re: [Rails] nil can't be coerced into BigDecimal

2012-02-21 Thread Peter Vandenabeele
On Tue, Feb 21, 2012 at 8:15 AM, LED leedap...@gmail.com wrote: hi guys im playing with RoR with the environment of rails 3 ruby 1.9 i got stuck in nil can't be coerced into BigDecimal error i need to get the total cost of the products inside the cart i know where the problem is(i think)

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread LED
Is there a business rule that each item must realistically have a quantity and product (and that product must have a price) ? uhm im following agile web development rails actualy the snippets are from the book * add validations for the presence of these values   (presence of quantity and

Re: [Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread Peter Vandenabeele
On Tue, Feb 21, 2012 at 9:48 AM, LED leedap...@gmail.com wrote: Is there a business rule that each item must realistically have a quantity and product (and that product must have a price) ? uhm im following agile web development rails actualy the snippets are from the book * add

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread LED
yes those data are valid actualy a while ago it worked but when i clear and destroy the cart it returned to this error very much appreciated for your effort thank you On Feb 21, 4:51 pm, Peter Vandenabeele pe...@vandenabeele.com wrote: On Tue, Feb 21, 2012 at 9:48 AM, LED leedap...@gmail.com

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
app/models/line_item.rb:24:in `*' app/models/line_item.rb:24:in `total_price' app/views/carts/show.html.erb:7:in `block in _app_views_carts_show_html_erb___389431939__618846538' activerecord (3.1.1) lib/active_record/associations/collection_proxy.rb:91:in `each' activerecord (3.1.1)

Re: [Rails] nil can't be coerced into BigDecimal

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 11:15, LED wrote: hi guys im playing with RoR with the environment of rails 3 ruby 1.9 i got stuck in nil can't be coerced into BigDecimal def total_price line_items.to_a.sum { |item| item.total_price } end model/cart.rb That error would be expected when

Re: [Rails] respond_to format.json not being called

2012-02-21 Thread Valery Kvon
On 20.02.2012, at 22:57, Oliver Fox wrote: Hi all, I'm submitting a form using jQuery, but in the respond_to block only the format.html action is called. This is the javascrip: send_button.on('click', function(){ var form = $(this).closest('.modal').find('form');

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
nil can't be coerced into BigDecimal def total_price line_items.to_a.sum { |item| item.total_price } end model/cart.rb That error would be expected when some of line_items.total_price returns nil. Moreover you can sum total prices without .to_a, that would be more efficient. tried

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
i tried refactoring my destroy method now its working fine but my second issue is when i add item to the cart at first attemp it returns to that error again but returning to the product list it worked fine im just wondering if my add_product is code is ok? def add_product(product_id)

Re: [Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread Valery Kvon
I didn't see you code completely, but line_items.to_a.sum { |item| item.total_price } How can it count correct if only ONE item in the cart? :) Obviously, if you want to get Array, use Array.wrap method like this: Array.wrap(line_items).sum { |item| item.total_price } On 21.02.2012, at

[Rails] Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
Valery Kvon wrote in post #1047975: I didn't see you code completely, but line_items.to_a.sum { |item| item.total_price } How can it count correct if only ONE item in the cart? :) Obviously, if you want to get Array, use Array.wrap method like this: Array.wrap(line_items).sum { |item|

Re: [Rails] Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread Colin Law
On 21 February 2012 09:39, ruby LED li...@ruby-forum.com wrote: Valery Kvon wrote in post #1047975: I didn't see you code completely, but line_items.to_a.sum { |item| item.total_price } How can it count correct if only ONE item in the cart? :) Obviously, if you want to get Array, use

Re: [Rails] nil can't be coerced into BigDecimal

2012-02-21 Thread Valery Kvon
def add_product(product_id) current_item = line_items.where(:product_id = product_id).first if current_item current_item.quantity = current_item.quantity.to_i + 1 else current_item = LineItem.new(:product_id=product_id) line_items current_item

[Rails] Re: Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
Colin Law wrote in post #1047978: On 21 February 2012 09:39, ruby LED li...@ruby-forum.com wrote: it feels like im adding a nil value at my first attemp of adding a product into my cart? It is not the item that is nil but total_price. If it were the item that were nil then you would get an

Re: [Rails] Re: Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread Valery Kvon
Show us the code of LineItem class. This method raises the error on a new instance. To avoid it, it must return BigDec anytime. In your case product.price is nil or quantity is nil.. def total_price product.price * quantity end On 21.02.2012, at 13:55, ruby LED wrote: Colin Law wrote

[Rails] Thread safety and class methods

2012-02-21 Thread cipher_neo
Hey guys, using passenger, is it possible that there could be thread safety issues when executing a class method on a model? I am seeing some weird data in some of my model instances and I think it may be to do with concurrent processing of a class method in a model. Is this possible, that

Re: [Rails] Re: Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread Peter Vandenabeele
On Tue, Feb 21, 2012 at 10:55 AM, ruby LED li...@ruby-forum.com wrote: Colin Law wrote in post #1047978: On 21 February 2012 09:39, ruby LED li...@ruby-forum.com wrote: it feels like im adding a nil value at my first attemp of adding a product into my cart? It is not the item that is

[Rails] Re: Re: Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
Valery Kvon wrote in post #1047982: Show us the code of LineItem class. This method raises the error on a new instance. To avoid it, it must return BigDec anytime. In your case product.price is nil or quantity is nil.. def total_price product.price * quantity end class LineItem

[Rails] Strange behavior, writing right to left

2012-02-21 Thread Marcin S
Hello, something strange happened to my app, and i can't fogure out whats it. for example when i type something in form field im wrting from right to left... when i have horizontal unordered list , the first element is most to the right too :/ does that ring a bell to anyone? -- You received

Re: [Rails] Re: Re: Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 14:08, ruby LED wrote: class LineItem ActiveRecord::Base belongs_to :product belongs_to :cart def total_price if product.price product.price = product.price * quantity else 0.to_d end end end So. I agree that: 1) current_item =

Re: [Rails] Strange behavior, writing right to left

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 14:13, Marcin S wrote: Hello, something strange happened to my app, and i can't fogure out whats it. for example when i type something in form field im wrting from right to left... when i have horizontal unordered list , the first element is most to the right too :/

[Rails] adding items to cart first attemp fail

2012-02-21 Thread ruby LED
hi im workiing on ruby on rails im just wondering if my add_product is wrong because when i add my product in to my cart at first attemp it fail and give me a nil cannot concien bigdecimal error but clicking return from my browser and add item at the second attemp it worked fine and but didnt

Re: [Rails] Strange behavior, writing right to left

2012-02-21 Thread Marcin S
2012/2/21 Valery Kvon adda...@gmail.com: On 21.02.2012, at 14:13, Marcin S wrote: Hello, something strange happened to my app, and i can't fogure out whats it. for example when i type something in form field im wrting from right to left... when i have horizontal unordered list , the first

[Rails] Re: Re: Re: Re: Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
Valery Kvon wrote in post #1047990: On 21.02.2012, at 14:08, ruby LED wrote: end end So. I agree that: 1) current_item = LineItem.new(:product_id=product_id) = BAD IDEA. Because, if you pass the invalid product ID, LineItem would be initialized as well, but the .product association

[Rails] Re: Why RoR over PHP Framework ?

2012-02-21 Thread Raimon Fs
Thanks for your comments, I'll keep you informed with the news (good or bad) :-) -- 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 post to this group, send email to

[Rails] Re: link_to param body

2012-02-21 Thread Tim Shaffer
Well you have at least two options to hide the parameters: You could change your link_to call and include :method=:post so it does actually send a post request. This doesn't really hide the parameters since the user can still view the source of the page and look at them. You could send them as

[Rails] Making ActiveResource work with nested attributes and fields_for

2012-02-21 Thread Dimas Cyriaco
Hello, I'm trying to make ActiveResource work with nested attributes and the fields_for tag. I started with a typical Rails application, with two ActiveRecord models with one to many relationship (one band has many members). In view 'bands/new.html.erb' I have something like this: %=

[Rails] API Authentication-Authlogic

2012-02-21 Thread Muruga
Hi all I am using Authlogic gem for authentication.I want an API authentication for external API(XML) call.How to implement this in authlogic .Thanks in advance... -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this

[Rails] Rails 2.3.11 config.ru File

2012-02-21 Thread Tom Rossi
I have a Rails 2.3.11 project that worked fine until I added the config.ru file (required by POW). Now when I deploy to Apache/ Passenger, I get the error: Missing the Rails 2.3.11 gem. The config.ru file contains the code I pulled form an old Rails guide: require config/environment use

[Rails] Conditional Logic on link_to with a block.

2012-02-21 Thread John SB
I've got some ugly code I don't know how to improve on. I've got a link_to tag that takes a fair amount of html as a block. I need the href value for the link to be different depending on some logic, there are four possible values for the href. What I ended us with was this, and it's pretty

[Rails] JS alter a rails form or have rails form variants conditionally on JS?

2012-02-21 Thread simpleton
I have a form with a JavaScript requirement because the page loads a JS file that creates a form input field with a certain Facebook- autocomplete kind of style: %= javascript_include_tag form_prettify_library % div class=box ul id=first_form class=tagitli class=prettify-new/li/ul %=

[Rails] JOB OPENING - Seeking Ruby on Rails Developers for Client (Medical Services) - Connecticut

2012-02-21 Thread Mayberry Recruiting
Two positions open for permanent, on site full time developers Visa candidates are welcome to apply. However, candidates must already be residing in the United States Client is offering a flexible work schedule after an acclimation period, but will require a minimum of 3 days onsite Salary: up to

[Rails] JOB OPENING – Seeking Two Experienced Ruby on Rails Developers for Client (online deals) – (Chicago)

2012-02-21 Thread Mayberry Recruiting
2-3 years Ruby on Rails web development experience with proficiency in a programming language and web application framework outside of Ruby and Rails Direct experience with the development and maintenance of large-scale, mission-critical web applications A solid understanding of database

[Rails] concurrent database hit performance issues

2012-02-21 Thread simpleton
After load testing my app, it started getting errors at 6 concurrent users on a not-at-all heavy SQL operation page and I want to know how to reduce these. I've read up about Connection Pooling but the information out there is scarce. I'd like to increase my pool limit to about 25-40 but what are

[Rails] Re: concurrent database hit performance issues

2012-02-21 Thread Frederick Cheung
On Feb 21, 8:16 am, simpleton brand.magn...@gmail.com wrote: After load testing my app, it started getting errors at 6 concurrent users on a not-at-all heavy SQL operation page and I want to know how to reduce these. I've read up about Connection Pooling but the information out there is

[Rails] Re: Conditional Logic on link_to with a block.

2012-02-21 Thread Tim Shaffer
Maybe just put the logic in the controller? if @brand.nil? if @store.nil? @brand_link_path = from_catalog_path(params[:id].blank? ? Category.root.id : params[:id], product.id, product.name_url) else @brand_link_path = from_store_path(@store.id, product.id) end else

[Rails] Re: concurrent database hit performance issues

2012-02-21 Thread simpleton
Certainly not using Thread.new yet. Thanks Fred. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to

Re: [Rails] nil can't be coerced into BigDecimal

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 15:29, ruby LED wrote: Valery Kvon wrote in post #1047990: I agree that: 1) current_item = LineItem.new(:product_id=product_id) = BAD IDEA. Because, if you pass the invalid product ID, LineItem would be initialized as well, but the .product association would return

[Rails] Update model with array of IDs

2012-02-21 Thread Rajarshi Chakravarty
Hi, I am trying to use the update method of activerecord with an array of ids as the first param. It does not update any row. The APIs say that it should work. The array contains 2 IDs. RSCampaign.update([1,2], {:end_date = Date.strptime(120228,%y%m%d)}) If I put an ID instead of the array, it

Re: [Rails] Update model with array of IDs

2012-02-21 Thread Michael Pavling
On 21 February 2012 15:25, Rajarshi Chakravarty li...@ruby-forum.com wrote: I am trying to use the update method of activerecord with an array of ids as the first param. It does not update any row. The APIs say that it should work. What error message do you get? Do both of those IDs map to

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
PS. Why are you writing product.price=? i belive it is same with product.price * quantity to show the sum of all products inside my cart Logic, logic, logic. product - is a stand alone instance or One product. Why Would it ever have the multiplied price with 'quantity' ?. I remember

[Rails] Search of multiple columns

2012-02-21 Thread Christopher Jones
I am currently writing a search method for my rails applications and at the moment it works fine. I have the following in my game.rb: def self.search(search) if search find(:all, :conditions = ['game_name LIKE ? OR genre LIKE ? OR console LIKE ?', %#{search}%, #{search}, #{search}]) else

[Rails] Search of multiple columns

2012-02-21 Thread Roger Patrick
I am currently writing a search method for my rails applications and at the moment it works fine. I have the following in my game.rb: def self.search(search) if search find(:all, :conditions = ['name LIKE ? OR genre LIKE ? OR console LIKE ?', %#{search}%, #{search}, #{search}]) else

[Rails] Re: nil can't be coerced into BigDecimal

2012-02-21 Thread ruby LED
PS. Why are you writing product.price=? i belive it is same with product.price * quantity to show the sum of all products inside my cart Logic, logic, logic. product - is a stand alone instance or One product. Why Would it ever have the multiplied price with 'quantity' ?. I remember

Re: [Rails] Search of multiple columns

2012-02-21 Thread Tom Meinlschmidt
IF you really need to search over several columns, use concat() for db columns... like scope :search, labda{|search| where(concat(name, genre, console) like ?, %#{search}%).presence || all } and then use Model.search('value') tom On Feb 21, 2012, at 16:44 , Roger Patrick wrote: I am

[Rails] Re: link_to 'Frob', '/thang/frob', :remote = true

2012-02-21 Thread Phlip
a href=/thang/frob data-remote=trueFrob/a Aaand that's the correct output, because the JS changed to DRY up the onclick handlers into rails.js: document.on(click, a[data-remote], function(event, element) { if (event.stopped) return; handleRemote(element); event.stop(); }); --

[Rails] Re: Update model with array of IDs

2012-02-21 Thread Rajarshi Chakravarty
Hey, I get no error message. It just doesn't update any record. Both the IDs are there in the DB table. -- 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 post to this group, send email to

[Rails] [ANN] Join us at RubyNation Mar 23-24

2012-02-21 Thread Gray Herter
Hi ruby fans, Tickets are on sale now for RubyNation, DC's Ruby and Rails developer conference. RubyNation will be held March 23-24th at the Sheraton in Reston, Virginia. Visit https://rubynation2012.busyconf.com/bookings/new to get your ticket. We are just over 75% full (less than 50 tickets

[Rails] Re: Search of multiple columns

2012-02-21 Thread Roger Patrick
Hey I found out my problem, it was because I did not have the % symbol in the last two search calls, all works fine now. Do you know how I would be able to make it as three separate search boxes and buttons instead of all going in to one? All I know is how to search every column under one form

Re: [Rails] Re: Search of multiple columns

2012-02-21 Thread Walter Lee Davis
On Feb 21, 2012, at 1:34 PM, Roger Patrick wrote: Hey I found out my problem, it was because I did not have the % symbol in the last two search calls, all works fine now. Do you know how I would be able to make it as three separate search boxes and buttons instead of all going in to one?

Re: [Rails] Update model with array of IDs

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 19:25, Rajarshi Chakravarty wrote: Hi, I am trying to use the update method of activerecord with an array of ids as the first param. It does not update any row. The APIs say that it should work. The array contains 2 IDs. RSCampaign.update([1,2], {:end_date =

Re: [Rails] Update model with array of IDs

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 19:25, Rajarshi Chakravarty wrote: Hi, I am trying to use the update method of activerecord with an array of ids as the first param. It does not update any row. The APIs say that it should work. The array contains 2 IDs. RSCampaign.update([1,2], {:end_date =

Re: [Rails] Can't seem to get javascripts to load in rails 3.1.3

2012-02-21 Thread Jason Fleetwood-Boldt
Vell-- With the asset pipeline, you don't include assets explicitly at /assets/application.js Instead, you use the asset pipeline and let it handle this for you. Re-read the Asset pipeline Rails guide carefully, make sure your config.assets settings are correct (remember, turned on by default

[Rails] Re: Update model with array of IDs

2012-02-21 Thread Rajarshi Chakravarty
Thank you, Valery. You are my hero. Can you please post a link to the APIs? -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com.

[Rails] Re: Re: Search of multiple columns

2012-02-21 Thread Roger Patrick
Take a serious look at ransack. It's a very neat search gem, and it allows you to create specialized search fields just by naming those It sounds really good Walter, do you have any links for Ransack, I just googles ransack - rails but it hasn't provided me with a documentation link. Thanks

Re: [Rails] Re: Update model with array of IDs

2012-02-21 Thread Valery Kvon
On 21.02.2012, at 23:42, Rajarshi Chakravarty wrote: Thank you, Valery. You are my hero. Can you please post a link to the APIs? api.rubyonrails.org or https://github.com/rails/rails/blob/d22592a05b299c21e30ec8b38890a178dca863b4/activerecord/lib/active_record/relation.rb#L312 people =

[Rails] Re: Can't seem to get javascripts to load in rails 3.1.3

2012-02-21 Thread Neener54
Do you have %= javascript_include_tag application % in your layout? On Feb 15, 11:13 am, Vell lovell.mcilw...@gmail.com wrote: Hello all, I am attempting to add some jquery to an application that I am developing but I am having trouble getting my newly created .js file to load. I have tried

Re: [Rails] Re: Re: Search of multiple columns

2012-02-21 Thread Peter De Berdt
On 21 Feb 2012, at 20:58, Roger Patrick wrote: Take a serious look at ransack. It's a very neat search gem, and it allows you to create specialized search fields just by naming those It sounds really good Walter, do you have any links for Ransack, I just googles ransack - rails but it

[Rails] How to call javascript method from controller or by Ajax?

2012-02-21 Thread testwishluck
Hi guys, In Rails framework, I need to call the lightbox to add payment method by using javascript method AuthorizeNetPopup.openAddPaymentPopup(). But based on the design, the popup should be triggered by other ways not by clicking the normal button. For example, users click signup button, the

[Rails] Scoped_views in rails2.3.5 with restful_authentication

2012-02-21 Thread Nirmala Agadgar
I am using rails 2.3.5 and restful_authentication plugin. User model is inherited by visitor, spotter and subscriber. How to implement scoped_views for different user(visitor, spotter and subscriber) registration. -- You received this message because you are subscribed to the Google Groups Ruby

[Rails] Parent id for find_or_create method

2012-02-21 Thread Soichi Ishida
Rails 3.1.3 I have tables, Video and Script having association, Video 1 --- n Script So, every Script needs the parent id, in this case, video_id. If I simply create a new Script instance, the view renders as follows. %= render :partial = new_script, :locals = { :script =

[Rails] Collect users who posted items with ActsasTaggable on Tag in rails 3

2012-02-21 Thread Aruna Chinnamuthu
I am using Rails 3 and Acts as taggable on in my application. I am fetching the articles associated with the tag by Article.tagged_with(tagname) and Blog.tagged_with(tagname) Now i would like to collect all the users from the above i.e.., people who are all posted articles and blogs with this

[Rails] Table filter

2012-02-21 Thread Tony N.
Bonjour,I'd like to filter the following table tr tha href=#Nom salle/a/th tha href=#Nom machine/a/th tha href=#Type d'incident/a/th tha href=#Informations/a/th th id=etata href=#Etat/a/th tha href=#Date création/a/th tha href=#Date résolution/a/th tha href=#Actions/a/th /tr

[Rails] Re: Could not read chunk size?

2012-02-21 Thread Dharmdip Rathod
Hi Jeff, I am facing same issue, do you have any solution ? -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe