ruby-on-rails

Rspec redirect_to routes are failing expectations (or misparsed?), how come?

It seems my rspec route for :controller => 'phones', :action => 'edit' works...it should be 'phones/123/edit', and IS according to rspec tests and rake routes. But when I create a redirect_to expectation, the expectation fails. Here's the routes test for the url: it "maps #edit" do route_for(:controller => "phones", :action ...

Google Calendar Event GUI

Hello, does anybody know, where I can find the Google Calendars Event-GUI? I'm building an social networking site, which relies on google calendar. For adding and changing events, I want to use googles GUI (i dont want to code this myself if there is a partial/control already existing). Does anybody know where I can find this? ...

what is the impact of rails 2.3's rack support?

Does it make any difference in terms of developing Rails apps now that it uses rack to talk to web servers? Should we do anything differently to take advantage of it? Is it just cleaner or does it have any performance improvement over the cgi implementation? ...

What are "specs" for in Ruby gems?

I was looking through the Datamapper directories and opened up dm-core/tasks/dm.rb. Just generally speaking, what the heck is going on in this file? It looks like Greek to me. Particularly this thing about "specs" - what are those for? Is that similar to a software spec which defines what a project is supposed to encompass? require 'spe...

Generating nested routes in a custom generator

I'm building a generator in rails that generates a frontend and admin controller then adds the routes to the routes file. I can get the frontend working with this: m.route_resources controller_file_name but I can't figure out how to do the same for the nested admin route (admin/controller_file_name). Anyone know how to generate these ...

ActiveRecord relationships for a join table linking two records of the same table?

I have a Character model and a Link model. The Link model represents a link from a character to another character. A link has a textual 'description' attribute. A link from character A to character B is distinct from the opposite link from B to A. A character has zero or one link to another character. A character may have various links t...

instance variable vs. symbol in ruby on rails (form_for)

hi, i'm new to ruby on rails and am working with version 2.3 on mac osx. i am trying to create the same functionality a scaffold creates, but on my own. i created a "post" controller, view, and model. in post controller, i have the following: class PostController < ApplicationController def index end def new @post = Post.new ...

Rails ActionMailer - format sender and recipient name/email address

Hi, Is there a way to specify email AND name for sender and recipient info when using ActionMailer? Typically you'd do: @recipients = "#{user.email}" @from = "[email protected]" @subject = "Hi" @content_type = "text/html" But, I want to specify name as well-- MyCompany <[email protected]>, John Doe <john.doe@myco...

Virtualhostname is not prepended to routes with Passenger 2.2.2 and Rails 2.3

Before the switch and in all apps on this passenger that run rails 2.0 my routes would yield "myapp/controller/action" Now they yield "controller/action". Interestingly the stylesheet_link_tags do work as normal. I prepend a prefix in the production environment to deal with this but it is a hideous hack of course. Any help is appreci...

Is the lift framework as "easy" as ruby on rails or django?

Just wondering if anyone has experience with the three. I have used read through some RoR and used Django. They seem fairly easy to use. Is lift "easy" like these two are? I know easy is subjective and has no context here. I mean in a very high level and general sense. ...

rails: displaying a user friendly message for a routing error in rails

hello, i am working in rails 2.3 on mac osx leopard. every time i type a url that does not exist in a rails application i get the following error Routing Error No route matches "/whatever_i_typed" with {:method=>:get} this is find for development, but i was wondering how i can make sure users see a friendlier 'oops! not found' page. ...

How do I write to a text file outside of the document root in Rails?

I want to a list of emails in a text file outside of my repository and doc root in ROR. But I need the application to write to it. What is the best way to accomplish this? My guess is a sym link but I'm not sure. I am also curious about where I should keep this text file. It is a list of emails to invite people to use my service. Th...

Base64 encoding/decoding when serializing an attribute to/from the database

When rails serializes an object to store in the database it uses YAML. I want to also use Base64 encoding/decoding when doing this so the YAML will be much more compact on INSERT and UPDATE statements. The objects I am serializing are rather large, and Base64 encoding is reducing my insert and update statement times by 70%. I've been cr...

How to sort authors by their book count with ActiveRecord?

Let's say I have Book model and an Author model. I want to list all authors sorted by their book count. What's the best way to do that? I know how to do this in SQL, either by doing where .. in with a nested select or with some join. But what I'd like to know is how to do this nicely with ActiveRecord. ...

PHP or Ruby on Rails for interactive community site?

I consider myself as an entrepreneur with basic programming skills. My main experience is with PHP, but mostly as a code breaker- meaning being able to figure out the basics and manipulate the code to my needs. Recently took up studying RoR and it seems easy to understand. I will be putting together some resources to build a niche socia...

What tip do you wish you'd been given on your first days as a Rails developer?

What specific piece of advice could have saved you from going down the wrong track, saved you lots of rework or just helped you generally? ...

Is there a setup_class/teardown_class for Rails tests?

I need to have a setup and teardown method for some Rails tests that is class or system wide, yet I have only found a way to define a regular setup/teardown that works on a per test level. For example: class ActiveSupport::TestCase setup do puts "Setting up" end teardown do puts "tearing down" end end will execute th...

Change a finder method w/ parameters to an association

How do I turn this into a has_one association? (Possibly has_one + a named scope for size.) class User < ActiveRecord::Base has_many :assets, :foreign_key => 'creator_id' def avatar_asset size = :thumb # The LIKE is because it might be a .jpg, .png, or .gif. # More efficient methods that can handle that are OK. ;) se...

Get matching route from URL in rails (again)

Hi, How can I get hold of the matching route for a url in rails? Given a url, I want to query the respective controller and action. Note, the current page isn't the url in question. This question has been posed before but wasn't answered. Cheers. ...

Using Rack::Session::Pool with Sinatra

Hi, I'm exploring Sinatra and I want to use sessions but I don't want them to be stored in a Cookie, I found Rack::Session::Pool which works very well. Now I want sessions to expire after a certain duration but I don't understand how to instanciate the Rack::Session::Pool and them use it in Sinatra. Any Clue ? ...