ruby-on-rails

What are your experiences with development frameworks and tools for building web applications?

I've been building web sites off an on for about 10 years. 2 years ago I started using ASP.Net. I'm working on 2 projects right now, one using ASP.Net MVC and the other using Java / JSF / Spring / Hibernate. I've also used other frameworks (cgi/perl, php, ASP, jsp, jsf). What do you think is the most productive programming environment...

When you say Ruby is reflective, does this mainly refer to "duck typing"?

I was reading a text describing Ruby and it said the following: Ruby is considered a “reflective” language because it’s possible for a Ruby program to analyze itself (in terms of its make-up), make adjustments to the way it works, and even overwrite its own code with other code. I'm confused by this term 'reflective' - ...

ROR Model Setup Question: Table Relationships

I'm developing a site that will have a model for users, a model for submissions, and a model for ratings. Each submission may have only one rating per user. My question is how should I set this up in my models? ...

Rails nested resources

Here's the routes.rb: map.resources :assignments, :shallow => true do |assignment| assignment.resources :problems end How do i get the url to edit a problem (/assignments/xyz/problems/abc/edit), in code? I have tried both edit_assignment_problem_path(assignment,problem) and edit_problem_path(problem). While the firs...

ActiveRecord::StatementInvalid when process receives SIGTERM?

In my Rails app, I have a script that updates some records in the database. When I send a SIGTERM to kill the script, it occasionally receives that signal while ActiveRecord is executing a query. This leads to an ActiveRecord::StatementInvalid exception being raised. I'd like to catch StatementInvalid exceptions that occur when they...

What Ruby on Rails image library should I use for making vocab cards?

I am making a flashcard builder in Ruby on Rails. What image libraries are recommended for Ruby on Rails? I've used ImageMagick and I've had memory issues on the servers. I hear ImageScience is good but I don't know if I can scale images and draw words on the images (a la lolcats style.) ...

MySQL Performance

Lately my queries before caching into memcache have been taking forever to process! In this example, it took 10 seconds. All I am trying to do is get the 10 most recent hits in this case. I am getting the feeling that it loads all 125,592 rows then only returns 10, am I right? # User@Host: root[root] @ localhost [] # Query_time: 10 L...

High-performance RSS/Atom parsing with Ruby on Rails

I need to parse thousands of feeds and performance is an essential requirement. Do you have any suggestions? Thanks in advance! ...

Is it possible to make ActiveRecord create objects for rows loaded using the :joins option?

I need to do something like this class User < ActiveRecord::Base has_many :abuse_reports end class AbuseReport < ActiveRecord::Base belongs_to :abuser, :class_name => 'User', :foreign_key => 'abuser_id' belongs_to :game end class Game < ActiveRecord::Base has_many :abuse_reports end @top_abusers = User.page(params[:page], ...

I get "Missing these required gems", but gems are installed

Hi, since I updated ruby using Mac Ports (on Leopard) I have got several problems and I also had to reinstall gems. Now when I run Mongrel I keep getting the error "Missing these required gems" followed by the list of gems that I required in environment.rb but that gems seems to be correctly installed as I see running gem list. I think t...

Refactoring in model: what's going wrong?

I'm currently trying to DRY up this initial verbose code: def planting_dates_not_nil? !plant_out_week_min.blank? || !plant_out_week_max.blank? || !sow_out_week_min.blank? || !sow_out_week_max.blank? end def needs_planting?(week) if !plant_out_week_min.blank? && !plant_out_week_max.blank? (plant_out_week_min..plant_out...

Problems with x_sendfile in Rails

I’m having some problems with John Guenin's x_sendfile (http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/). When coding the download of a PDF file, I’m using the following code: def send_the_file(filename) xsendfile (“#{Rails.root}/doc/” + filename, :type => ‘application/pdf’) end but I only get 1 byte downloaded...

In Rails, do you need to use form_authenticity_token if you're already checking if a user is logged in?

Because form_authenticity_token is used to validate requests, is it redundant to use it when you're already checking whether a user is logged in? I.e., is form_authenticity_token really intended only for forms which are available to anyone, as opposed to forms exclusively for logged-in users? ...

Where can I promote Rails applications?

I am currently writing a FOSS Rails app and would like to get some ideas about where to promote the application. I am searching for something like opensourcerails.com or wiki.rubyonrails.org/rails/pages/OpenSourceProjects ...

Speed up Rails App on development env.?

Hi. I have huge Rails app on development right now, which run VERY slow on -e development. I use Mongrel as web server. Is there any way to speed up a little bit everything? Because i have to wait 3-10 sec. to reload a page. Thanks. ...

Is there a sample Rails application with a number of cucumber stories?

I'm trying to really understand Cucumber stories. I get it, but I'm really slow writing them. I think if I saw a good fleshed out application, I'd get closer to where I want to be. There are some samples out there, but there aren't any I can find with a single app with some non-contrived example stories. Are there any existing ones? ...

Where Is The Recommended Place To Store Instance Variables For Layouts

If you have a layout that has in a menu which gets its menu items from a database. Where is the recommended place in a Rails application to place that call and assigns it to the instance variable that the layout uses? 1. @menuitems # exists in application.html.erb 2. @menuitems = MenuItem.find(:all) # code exists somewhere (where should...

Python or Ruby for a .NET developer ?

I'm a C# .NET developer and I work on mostly ASP.NET projects. I want to learn a new programming language, to improve my programming skills by experiencing a new language, to see something different then microsoft environment, and maybe to think in a different way. I focus on two languages for my goal. Python and Ruby. Which one ...

Testing a sweeper with RSpec in Rails

I want to make sure my sweeper is being called as appropriate so I tried adding something like this: it "should clear the cache" do @foo = Foo.new(@create_params) Foo.should_receive(:new).with(@create_params).and_return(@foo) FooSweeper.should_receive(:after_save).with(@foo) post :create, @create_params end But I just ...

Cannot access http://localhost:3000

I am trying to learn Ruby on Rails, I have followed the instructions from this page to get rails installed on my PC. I am also trying to follow this webcast to try and learn the language and framework. Everything is working so far, apart from the fact that I cannot access http://localhost:3000 http://0.0.0.0:3000 http://127.0.0.1:3000, ...