ruby-on-rails

Anyone has a link to Rails (2.3.8) RJS Api?

Hey guys, do any of you know any good reference for the RJS mechanisms in Rails (2.3.8) I can find a few examples from like 2006/2007 and no actual documentation. ...

Rails 2.3.5 I18n month/day name translation problem

My config/locales/pl.yml file (sampled from here): pl: date: day_names: [Niedziela, Poniedziałek, Wtorek, Środa, Czwartek, Piątek, Sobota] month_names: [~, Styczeń, Luty, Marzec, Kwiecień, Maj, Czerwiec, Lipiec, Sierpień, Wrzesień, Październik, Listopad, Grudzień] In script/console: I18n.locale = 'pl' => "pl" Time.now.strf...

RoR link_to_remote :success and prototype

Hi, I am creating navigation for a list of categories. When a user click the link I want to change the background color of the link to show that it is currently selected. I get that to work this code: <% get_category_list.each do |c| %> <li><%= link_to_remote "#{c}", {:update => "list_inner", :success => " $('#{c}').setStyle({b...

Import MySQL-DB-Dump into a Rails app using a migration file

I have an old PHP application with a bunch of MySQL tables. I want to rewrite it with Rails(3) and want to import the old data. How can I write a migration-script to import the MySQL-Dump into a sqlite DB? ...

Rails 3 Active Record Initialize Search Chaining

I have a search function that performs basic filtering in a Rails 3 application (using the new method chaining). The filtering uses optional parameters and looks something like this: class User < ActiveRecord::Base def self.search(params = {}) users = User.? users = users.where(:sin => params[:sin]) if params[:sin] ... ...

Should I use the template to render JSON or use Controller returning JSON in RoR?

That's my great doubt. We have a project in RoR and we are making it more dynamic, using Ajax calls. They want that I put literal JSON in html templates and parse it with eval() in javascript, avoiding to putting exception into Controller to return response as JSON directly. Example: WhateverControoler#index -> will render views/whatev...

Upgrade rails applications from rails 2.3.8 to 3 on windows.

Anyone can provide links to upgrade my rails application from rails 2.3.8 to 3 on my windows machine ... ...

In Ruby on Rails, if we generated a model "Animal", and now want to have "Dog", how should we do it?

say, if we generated a model rails generate model animal name:string birthday:date and now we want to create other model to inherit from it (such as Dog and Cat), should we use rails generate model again or just add the files ourselves? How do we specify Dog should inherit from Animal if we use rails generate model? I think if we us...

Paperclip with S3 on Rails 3 / uninitialized constant AWS::S3::Connection

I'm trying to upload a file to s3 using paperclip and get this error when making a new object and referencing the variable: the aws-s3 gem is installed the s3.yml file has the correct credentials ie: a = Attachment.new a.file NameError: uninitialized constant AWS::S3::Connection from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/li...

How to use the rails match method with a string?

Is there a way to use the rails match method with a simple string, rather than a regular expression? I'm trying to match a url as such sometext.match('http://www.example.com') The problem is, this is stil getting evaluated as a regular expression, so I have to escape all the special characters for this to work properly, as such: some...

Rails/Passenger sub URI error

I am attempting to deploy a rails 3.0.0 application to a sub URI using passenger 2.2.15. I believe I've made the correct RailsBaseURI changes to my http.conf , have symlinked the sub URI to the public directory of my app and added the following line of code to environments/production.rb: config.action_controller.relative_url_root = "/s...

How can I choose Ruby version on Heroku?

I use Ruby 1.9.x syntax in my Rails 3 app, but after pushing it to Heroku it crashes due to older Ruby version (1.8). How can I control it? ...

What is the most common way to do authentication in rails 3?

I need to do authentication in rail3 with standard sign up/login/forgot password functionality. Is there a plugin or something that most people use for this? ...

Autocomplete stop work after page refreshed

Hi, I am new to both Rails and Javascript, so my question is probably trivial. I am currently building a website which have a side page for index page. Inside the side panel, there is a search field for the index page, which I used for autocomplete ( Ajax.Autocompleter from the script.aculo.us). The problem is that seems autocomplete ja...

Using Mongoid (MongoDB mapper for Ruby on Rails), why s.save returns true but record not updated?

If the following code is run twice, both times s.save will return true, indicating success, but the second time, the time won't be updated? foo = Foo.new foo._id = 100 foo.time = Time.now p foo.save ...

How to add attribute to Nokogiri node?

I'm trying to add an attribute to an existing Nokogiri node. What I've done is this: node.attributes['foobar'] = Nokogiri::XML::Attr.new('foo', 'bar') But I get the error: TypeError Exception: wrong argument type String (expected Data) What is a Data data type, and how do I add an attribute to the Nokogiri object? Thanks! ...

Rails and getting the amount of days dates overlap

Hi, lets say I have a user, this user has many trips and belongs to a city. Each trip belongs to a city and has a start and an end date. Lets say user X goes to new york between 2010-09-01 and 2010-09-20, now I want to know who else is in new york and for how long their trips overlap with user x. And then there are people already liv...

Setting up Mysql for Ruby on Rails in Windows

I'm on Windows, and I have a working Rails 2.3.8 app on Ruby 1.8.6 with MySQL 5.0 and the mysql gem version 2.8.1. It all works. I just installed Ruby 1.9.1, installed gems for rails(2.3.8) and mysql. BUT NOW when I run ruby script/server: !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and...

Table format in Hirb for .where Rails 3 queries

I am using http://tagaholic.me/hirb/ to format AR queries in console with pretty, MySQL like table views. The problem is, that by default Rails 3 .where queries, reaturned as ActiveRecord::Relation arent displayed in a table format. With imported table method everything is formatted properly. How to set default display to table in Hirb ...

How to apply conditions when accessing records using a has_many through relationship in Rails?

Hi, I have the following models: class Campaign < ActiveRecord::Base has_many :campaign_keywords has_many :leads, :through => :campaign_keywords end class CampaignKeyword < ActiveRecord::Base belongs_to :campaign has_many :leads end class Lead < ActiveRecord::Base belongs_to :campaign_keyword end I am trying to buil...