ruby-on-rails

how to go from beginner level to proficient level with ruby on rails?

i need some advice since i have read 4 books for beginners in ROR.should i contribute to open source projects?how ?where can i find project that are easy enough to improve my skills. thank you. ...

Ruby on Rails custom Observer

Could anyone advise how to use custom observer or events/callbacks in Ruby on Rails? I have tried both these posts: http://www.mutuallyhuman.com/2009/1/6/using-custom-activerecord-events-callbacks and http:// alexkira.blogspot.com/2008/10/custom-observer-callbacks-in-rails.html none seems to be working. On the second post, I put Alex ...

Fall back to default language if translation missing

Hello, in an internationalised Rails (2.3.5) app, I'd like to show a translation from the default locale instead of "translation missing" - there's a ticket for it but it seems it's still pending: https://rails.lighthouseapp.com/projects/8994/tickets/2637-patch-i18n-look-up-a-translation-with-the-default-locale-when-its-missed-with-ano...

Rails Math.radians

I need Math.radians() function and can not find it. Thx for help. radians=(angle/180)* Math::PI ...

How do I use Rail3's AREL by itself?

I'm intrigued by Nick Kallen's AREL package and would like to use it in a project. However, I can't figure out on how I need to initialize it to work with a specific database/store backend. Any pointers? ...

Return original selection in collection_select when editing entry

Hello boys and girls. I'm trying to get my head around collection_selects in Rails. I can populate the dropdown from a database table, submit the selected option, and show the result. However I can't figure out how to show the selected option in the dropdown when the user chooses to edit the entry. Here's an extract from my view code: ...

Creating associated models on create in Rails?

I have to be dead tired because I really can't figure out such simple task as this. Having: class Account < ActiveRecord::Base has_one :subscription, :dependent => :destroy after_save :append_subscription private def append_subscription # TODO end end # Subscription(id: integer, account_id: integer, level: integer (: ...

Linking new users signed in via Facebook connect to existing accounts

I have recently implemented login to my via facebook connect. So now users have 2 ways of logging in to the site. The old way of registering an account and the new way (facebook connect). One thing I would like to do is link a new facebook connect user account to existing accounts if they logged in the old way. Has anyone had any succe...

CLI-Based "V" in Rails MVC?

Having a hard time getting any useful results from various searches on this concept -- probably because it's a. Wrong and/or b. obscure. Essentially, though, I'd like to write an application which works as either a normal web app or with a command-line interface. I've done this in the ancient past for sysadmin-y stuff using Perl, but t...

rails validation contigent on multiple elements

I've been using accepts_nested_attributes_for for a few different models and I've got an odd situation. I can skip creation blanks thru the top model, and I can validate_presence of individual records thru the bottom, but is it possible to do a most complex validation on a set of records? I have the models Rooms and Rates. Rooms has_m...

Anyone using Django in the "Enterprise"

I know that the word “enterprise” gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say… Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind of viewed as THE enterprise...

Connecting to MySQL with --skip-ssl from Rails app

When connecting to MySQL from shell line i need to add the option --skip-ssl From my rails app I can't connecto to the MySQL server. How can I add this option to the rails app? ...

How do I get .try() working in a Rails module?

With Rails 2.3.5 I've written a module in RAILS_ROOT/lib/foo.rb which I'm including in some models via "include Foo" and all is well except where I try to use some_object.try(:some_method) in the module code - it throws a NoMethodError rather than returning nil like it would from a Rails model/controller/etc. Do I need to require a Rail...

Identifying a item in one of multiple ways

I'm designing a form where you need to add a relation to another object. Okay that's normally fine, but what I am hung up on is a clean way to make it easy for the user to enter the object. There are multiple ways that the user could know how to specify the object (unique identifiers). Let's take the example of associating a user to ...

How to consume YUI editor events

I think this is a simple question, but I can not find the answer I have a rails app and I am using jquery and the YUI Rich Text Editor, I want to write some javascript/jquery to to have a minimum text length counter (i.e. you have 240 characters left). I have it working with a simple text-area: jQuery.fn.populateCounter = function()...

What are common ways of implementing web API request throttling/rate-limiting?

What are common ways of implementing web API request throttling? Are there any libraries for common web frameworks (Rails, Django, Java, etc.) that give you this along with temporary banning? A related question suggests that the rate limiting is done at the web server by limiting requests by IP, but that would mean that all requests are...

Exporting large amounts of data using FasterCSV with Rails

I have a controller in Rails that generates CSV reports using FasterCSV. These reports will contain approximately 20,000 rows, maybe more. It takes about 30 seconds or more when creating the csv_string in my implementation below. Is there a better/faster way to export the data? Any way to output the data without having to store it all i...

Rails callbacks (after_create)

Hey. I would like ActiveRecord to et some DB field automatically using callbacks. class Product < ActiveRecord::Base after_create :set_locale def set_locale self.locale = I18n.locale end end In ./script/console I do p = Product.create p Field p.locale is not set. What did I do wrong? Thx for help! ...

Error using private or protected methods in subclasses of ApplicationController

I have a filter shared between some controllers, wich is primarily declared as private in ApplicationController. This method sets find and pagination conditions for controllers. class ApplicationController < ActionController::Base ... protected # or private # Define parametros de busca def set_find_opts(klass) @filter ...

Rake task which consumes many data freezes

Hi all, I have a simple rake task which consumes pretty much data via ActiveRecord. (contacts has ~47k rows) Contact.all.each do |contact| contact.update_attribute ... end When I run that task ~400 rows get updated and then the task stucks. No errors and no database activity at all... How do I make this work properly? ...