ruby-on-rails

Radiant extension

Im developing a simple extension to Radiant. I created a controller, using the generator available, like class NewsletterController < ApplicationController no_login_required skip_before_filter :verify_authenticity_token def send @news = Newsletter.find_or_create_by_email(params[:email]) @news.save flash[:notice] = "You...

Exception Errno::EPIPE in Passenger RequestHandler (Broken pipe)

Hi, Upgraded to Rails 2.3.2 and Passenger 2.2.4 on Ubuntu hardy slice at slicehost with Apache2 I'm getting this same above discussed error in my Apache error.log of system /var/logs/apache2/ [ pid=4249 file=ext/apache2/Hooks.cpp:638 time=2009-07-04 11:47:32.752 ]: No data received from the backend application (process 4383) within ...

Ruby Programmer collaboration with Graphics Designer: Best practices?

I've been programming for many years and have just recently got the RoR "itch". I'm thinking about how I could utilize a graphic designer and wondered how best to collaborate with them: 1) Do scaffolding and then show them where to place the graphics in the views (seems ugly) 2) Have them do screens and make them keep a certain dir st...

RESTful Content Negotiation in Rails

I'm looking to implement content negotiation on some resources in a Rails app. I'm using Mootools and will likely be able to tweak the content type accepted by an XMLHTTPRequest to "application/json". Is there any way to pick up on this information in my controller and generate JSON responses instead of XHTML? I'm trying to avoid doin...

Can you explain what's going on in this Ruby code?

I'm trying to learn Ruby as well as Ruby on Rails right now. I'm following along with Learning Rails, 1st edition, but I'm having a hard time understanding some of the code. I generally do work in C, C++, or Java, so Ruby is a pretty big change for me. I'm currently stumped with the following block of code for a database migrator: d...

Importing Contacts from GMail - Design Question

So, I am using Google Contacts API to let users import their contacts from GMail. I want the users to be able to select the contacts they want to import in my app, So currently I - GET a XML feed of all the contacts a user has. Parse it, and for each contact create a record in the imported_contacts table. Display the list to the user,...

Help interpret will_paginate docs?

Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults to 1 if false or nil :per_page — defaults to CurrentModel.per_page (which is 30 if not overridden) :total_entries — use only if you manually count total entries :count — additional options that are passed on to count :finder — name of th...

Non-Windows RAD Web development

I have spent most of my web-development career in the Microsoft camp, but for different reasons I am trying to look at options. Some years back I did a bit of Java/Struts development in eclipse, which was nice for its time but my memories of it are not close to what Visual Studio delivers today. Some of the strengths of the MS stack a...

has_many through update issue

Hi there, Been trying to sort this for over a day now, and I am sure that it is something simple that I am missing. I have a project, which can have one main category and two optional categories. My relevant code for the project model: has_many :project_categories has_one :optional_category_1, :through => :project_cate...

(Rails,Javascript) RJS "Can't find variable" error not providing detailed information.

Hi All, I'm having an issue with rails involving javascript. Basically, I have the following code: <ul id="all-points"> <%for point in Point.find(:all)%> <%domid = "point[all][#{point.id}]"%> <li class="available-point" id='<%=domid%>'> <span> <%= link_to_remote "ADD",:url => {:action => "add_point"}, :html ...

How do I generate dynamic items dynamically?

Hi All, I'm looking for a way to append elements with javascript using javascript. Basically I have two lists of items. One has a list of items with an "ADD" button (using "link_to_remote") and the other has a list of items with a "REMOVE" button (using "link_to_remote"). When I click the "ADD" it immediately places the item into the...

Use custom route upon model validation failure

I've just added a contact form to my Rails application so that site visitors can send me a message. The application has a Message resource and I've defined this custom route to make the URL nicer and more obvious: map.contact '/contact', :controller => 'messages', :action => 'new' How can I keep the URL as /contact when the model fail...

Should ASP.NET MVC developers really learn Ruby on Rails?

Hey guys, Today, I came a cross a blog post for David Hayden explaining why he thinks ASP.NET MVC developers should learn Ruby on Rails. Some of the reasons David mentioned: ASP.NET MVC was inspired by Rails and in order for me to be a smarter ASP.NET MVC Developer I feel like I need to know Rails. IronRuby is well on its way to...

Can't send complex json data to server using prototype and rails

Hello, I'm trying to send the following data to the server but at the server side I don't see the json parameter that I'm sending. Can anyone tell me what I'm doing wrong? Bellow you can see the code. Prototype: send_data_url = "change" hash = $H({"blocks": [{"h": "2", "area": [{"width": "96%", "els": [{"title": "first", "mand"...

Getting only new mail from an IMAP server

I am writing a client application that fetches emails from an IMAP server and then stores them in a database. The problem is that once I have checked the mail, the next time I only want to download the mail that has arrived since. So if I had checked the server for mail two hour ago, I only want to get the mail that has arrived in the la...

Rails dependencies issue when in production mode

Im working on a legacy oracle database with a slightly odd table naming convention where each column name is prefixed with the tables initial letters - eg policy.poli_id. To make this database easier to work with I have a method set_column_prefix that creates accessors for each column with the prefix removed. ie: # Taken from wiki.ru...

How do I retrieve specific attributes of a relationship/collection?

Hi All, Is there a good way to retrieve all of a specific attribute from a relationship/collection? For instance, I want a list of all the names of a person's cars. Obviously I can't do the following: Person.Cars.Name(s) ...but does something of that nature exist in ruby (or is there an ActiveRecord helper method) that handles that?...

Typecasting a custom column in rails ActiveRecord?

Let's say we do: default_scope :select => '*, 1+1 AS woah' in a model, we can then access woah as a method on the model, but it's a string. How do we typecast this so that it's an integer? In my real-world example I'm actually selecting an id from a joined table but it's being typed as a string. I need it to be a ruby integer. ...

RoR segfaults when accessing MySQL database

I'm running Ruby on Rails on a Solaris 10 server. I just reinstalled Ruby today to get things to work correctly with my MySQL system so I could add a new application I've been working on. I also updated my gems and the system. MySQL is the only thing in this system that hasn't been updated lately, that's at version 5.1.25. When I run th...

Tracking model changes in Rails, automatically

In my rails app I would like to track who changes my model and update a field on the model's table to reflect. So, for example we have: class Foo < ActiveRecord::Base before_create :set_creator belongs_to :creator, :class_name => "User" protected def set_creator # no access to session[:user_id] here... end end Wh...