ruby-on-rails

Upgraded a site from PHP to rails. What about missing old pages redirected from google?

Hi, I created a rails app for my client. It was PHP and I totally rebuild it from the scratch with rails. The problem is that the site is old and many old pages are ranked in google. Naturally many people will click the page link in google and the page won't be available. How do you usually handle such a problem? I need to redirect su...

gmail-like popup checkbox list in rails?

I need to build something like what gmail does for it's labels... It has a button that when pressed pops up a scrolling list displaying the labels with checkboxes for selection. I'd like to hear about approaches to do the popup and how to place it right under the button. Also, I'd like to be able to observe the checkbox select/deselect...

Ruby on Rails getting HTTP 500 with no error logged (hosted on Media Temple)

Hi, I am trying to deploy my Ruby on Rails application on Media Temple. The application starts fine (Mongrel starts up fine) but I keep on getting a HTTP 500 error. The problem is that nothing gets written to the log, so I do now know what might be causing this problem. I have 256M of memory available so I do not believe memory is a...

Ruby on rails: create_fixtures memory problem....

Hello, I have to create around 100k records. Those records are in the csv file and are being loaded using create_fixtures function. It's slow on my development machine but it completes. The problem starts on production where we have memory limits per process which leads to killing the rake process. I think it's because the create_fixtu...

Using Rails Migration on different database than standard "production" or "development"

Hi! I have a rails project running that defines the standard production:, :development and :test DB-connections in config/database.yml In addition I have a quiz_development: and quiz_production: definition pointing to a differnet host/db/user/password My goal now is to define a Migration that uses "quiz_#{RAILS_ENV}`" as its database ...

Rails: do we have anything built-in to output a ruby array as arguments to a javascript function call?

Hi, Here's what I want, in wishful code: in my controller action: @javascript_function_args = [ "foo", "bar", 1, [2, 3], { :zort => 'narf', :nom => 'cake' }] in my erb view: <script … > performAwesome(<%= @javascript_function_args.to_js_args %>); </script> or, even better: <%= call_javascript_function :performAwesome, *@java...

retrieving page title in rails

Curious as to how to approach this same problem using ruby / rails - http://stackoverflow.com/questions/399332/fastest-way-to-retrieve-a-title-in-php Is there a plugin or gem that anyone recommends? cheers! ...

rails time demon in my machine... it eats 2 hours have checked everything!

I have my checked my environment.rb config.time_zone = 'Prague' Nothing in development.rb regarding time This seems to work, in theory... Time.zone.now # Thu, 10 Sep 2009 17:51:35 CEST +02:00 also correct... Time.now # Thu Sep 10 17:52:10 +0200 2009 mysql... SELECT NOW() # 2009-09-10 17:53:48 correct! but when I create a new ...

how to calculate next, previous business day in rails

how to calculate next, previous business day in rails. ...

what are the advantages of mocha over rspec's built in mocking framework?

I notice that a lot of people prefer mocha over rspec's built in mocking framework. Can someone explain the advantages of mocha, or any alternative, over rspec's built in mocking framework? ...

Rails - Override primary key on has_one

I have the following associations, basically I want to link via userid and not the id of the object. class Tweet < ActiveRecord::Base has_one :user_profile, :primary_key => 'userid', :foreign_key => 'twitter_userid' class UserProfile < ActiveRecord::Base belongs_to :tweet, :foreign_key => 'userid' However the following spec fail...

Between Passenger and Rails, url-encoded underscores in urls aren't being handled properly

I have a Rails app deployed to my server under the context scala_tour. When going to the URL, everything works great. However, if the url is encoded to scala%5ftour (which is what SO does, incidentally), I get an error from Rails and/or Passenger. Passenger seems to recognize the URL and hands it off to my Rails app, but the Rails ap...

render collection of partials as html in rails

I am using jQuery to do an ajax call to my controller, and everything is working perfectly, except I can't quite get the return value that I want. Let's say I have a collection of items, and I have the partial: /app/views/messages/_message.html.erb I am trying to render it as a big string of text/html like so: format.js { render_to_...

Using arrays of objects in a form_for

Lets say I have something like the following: class Item def initialize @description, @price = descr, price end end class Shop def initialize @items = [] end def add_item(item) @items << item end end Is there a way to use a 'Shop' object in a form where each 'item' (or a field in the item) is a checkbox and n...

Should is_paranoid be built into Rails?

Or, put differently, is there any reason not to use it on all of my models? Some background: is_paranoid is a gem that makes calls to destroy set a deleted_at timestamp rather than deleting the row (and calls to find exclude rows with non-null deleted_ats). I've found this feature so useful that I'm starting to include it in every mode...

Should I build Flash-based chat with rubyAMF?

just what the question says, but here is more info - project involves creating a Flash front-end to a RESTful Rails app that will load banner ads, twitter feed, list of movies, etc. all read-only as far as Flash is concerned (for now). There will also be a live chat window with the ability to create private rooms. Is there anything...

session[] doesn't persist across cucumber steps

Every time this step Given /blah.../ ... cart = session[:cart] ||= Cart.new ... end runs in a scenario, it creates a new cart as opposed to (starting from the second call) picking one up from the session. Anyone knows how to fix that? I am on rails 2.2.2, cucumber 0.3.98, webrat 0.4.4 P.S. Possibly adding selenium into ...

Smarty Pants-like functionality in Rails

Smarty Pants sounds like a cool idea to me: SmartyPants can perform the following transformations: Straight quotes ( " and ' ) into “curly” quote HTML entities Backticks-style quotes (``like this'') into “curly” quote HTML entities Dashes (“--” and “---”) into en- and em-dash entities Three consecutive dots (“...”) into an ellipsis en...

Create a new reservation via a restful url?

Hi All, I have a html table which consists of columns for days, and rows for hours of the day. I intend this to be a UI widget, similar to the commonly seen calendar date picker. Clicking on a particular cell of the table would select that date and time for creating a new reservation. I was considering using a url to represent this se...

Is it easy to add e-mail verification down the road with restful_authentication?

Working on a new app and using restful-authentication. I was trying to make it as simple as possible to start and then iterate, so I didn't generate with the activation email functionality, planning to add it later down the road. Is there an easy way to do this later on using the existing plugin? ...