ruby-on-rails

In Rails, after using find with :select, my objects don't save

Running something like: @users = User.find(:first, :select => "name, lastname, salary") for @user in @users do @user.salary = 100000 @user.save end After this looking up in the Mysql table, the users aren't updated. ...

What is your preferred way to produce charts in a Ruby on Rails web application?

I'd like to add some pie, bar and scatter charts to my Ruby on Rails web application. I want want them to be atractive, easy to add and not introduce much overhead. What charting solution would you recommend? What are its drawbacks (requires Javascript, Flash, expensive, etc)? ...

Why does Rails cache view files when hosted on VM and codebase on Samba share

I have the following setup: Code on my local machine (OS X) shared as a Samba share A Ubuntu VM running within Parallels, mounts the share Running Rails 2.1 (either via Mongrel, WEBrick or passenger) in development mode, if I make changes to my views they don't update without me having to kick the server. I've tried switching to an N...

if you reimplemented twitter, what would you do differently?

I just saw the hilarious "The Rise and Fall of Twitter" which made me think: if you reimplemented twitter, what would you do differently? What technologies would you use? What languages? How do you ensure that the service is scalable? What else would you change? ...

Using Merb for Facebook Application

Since Rails is not multithreaded (yet), it seems like a threaded web framework would be a better choice for a Facebook application. (reason being is cuz each Rails process can only handle one request at a time, and facebook actions tend to be slow, because there is a lot of network communication between your app and facebook) Has anyon...

Renaming controllers in Rails and cleaning out generated content.

I was following along with the railscast regarding the restful_authentication plugin. He recommended running the command: script/generate authenticated user session Which I did, and everything generated "fine", but then sessions wouldn't work. Checking the site again, he mentions a naming standard and listed updated code which stated:...

What's the best way to run Wordpress on the same domain as a Rails application?

I've got a standard Rails app with Nginx and Mongrel running at http://mydomain. I need to run a Wordpress blog at http://mydomain.com/blog. My preference would be to host the blog in Apache running on either the same server or a separate box but I don't want the user to see a different server in the URL. Is that possible and if not, w...

How to Implement a Redirect on All Requests (on certain conditions)?

I want to set something up so that if an Account within my app is disabled, I want all requests to be redirected to a "disabled" message. I've set this up in my ApplicationController: class ApplicationController < ActionController::Base before_filter :check_account def check_account redirect_to :controller => "main", :action =...

How does has_one :through work?

I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through => :pack_release_items end class Pack < ActiveRecord::Base has_many :pack_release_items has_many :release_items, :through=>:pack_release_items end class PackReleaseItem < ActiveRecord::Base belongs_to :pack belo...

How would I store a date that can be partial (i.e. just the year, maybe the month too) and output it later with the same specifity?

I want to let users specify a date that may or may not include a day and month (but will have at least the year.) The problem is when it is stored as a datetime in the DB; the missing day/month will be saved as default values and I'll lose the original format and meaning of the date. My idea was to store the real format in a column as a...

A visual MySQL tool for Ubuntu

Hi all I have recently installed Ruby on Rails on my new Ubuntu machine (first time for me) and i was working through a demonstration on setting up a sample blog. Basically, i came to the part of setting up the mysql database and would rather use a visual MySQL tool to do this rather than command line. What is best to use? and how do ...

Ruby on Rails Migration - Create New Database Schema

Hi I have a migration that runs an SQL script to create a new Postgres schema. When creating a new database in Postgres by default it creates a schema called 'public', which is the main schema we use. The migration to create the new database schema seems to be working fine, however the problem occurs after the migration has run, when ra...

best IDE for ruby on rails

Having moved from java to ruby, I am struggling to find a good IDE for ruby. I used eclipse on java, so I tried Aptana Studio (previously Radrails), but its not even half as good. Currently I am trying out Netbeans for Ruby. Please suggest me the best RoR IDE out there. I believe TextMate is universally accepted as the best editor on ...

Rails or Django? (or something else?)

I'm interested in learning a web framework. The two big ones, as I gather, are Rails and Django. Which one is better/faster? Is one better designed or more logically consistent than the other? Is there another framework I should look into? How easy is it to set up and administer a Rails or Django server, and how easy is it to find a shar...

versioned rails db and differ

I'm wondering if there's an integrated solution to have a database with versioned records supported by rails (ala version_fu ar_versioned) and a differ thanks! ...

How do you mock params when testing a Rails model's setter?

Given the code from the Complex Form part III how would you go about testing the virtual attribute? def new_task_attributes=(task_attributes) task_attributes.each do |attributes| tasks.build(attributes) end end I am currently trying to test it like this: def test_adding_task_to_project p = Project.new para...

What Does ActiveRecord::MultiparameterAssignmentErrors Mean?

I have a rails form with a datetime_select field. When I try to submit the form, I get the following exception: ActiveRecord::MultiparameterAssignmentErrors in WidgetsController#update 1 error(s) on assignment of multiparameter attributes If it's a validation error, why don't I see an error on the page? This is in Rails 2.0.2 ...

How does the ActiveRecord pattern differ from the Domain Object or Data Mapper pattern?

I was looking at DataMapper, which appeared at first glance to use the ActiveRecord ORM pattern. Other people said that it uses the DataMapper and/or the Domain Object pattern. What is the difference between those patterns? ...

How to fix / debug 'expected x.rb to define X.rb' in Rails

I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow. To use a real world example this occurred to me this morning: expected announcement.rb to define Announcement The class worked fine in development, testing and from a production console, ...

Specifying model in controller?

I came across a controller in an older set of code (Rails 1.2.3) that had the following in a controller: class GenericController > ApplicationController # filters and such model :some_model Although the name of the model does not match the name of the model, is there any reason to specify this? Or is this something that has d...