ruby-on-rails3

How to completely wipe rubygems along with rails etc

Ok, so I decided I'd be cool and try to use Rails3 that's in beta. Then, things were getting hard to manage so I got rvm. I installed ruby 1.9.2-head in rvm and things were working, and then a computer restart later rails wouldn't start up. So I figured I'd just try running the system ruby and start rails in it. same error. Then, I unins...

Rails3 UJS example with unobtrusive dry flash error

Hi to everybody thislink text is a demo "done right" about rails3 and UJS, but if you add: validates :name, :presence => true to the Task model that error(500 Internal Server Error) is displayed nowhere. Do you know a correct and clean way to handle it? ...

Rails 3 CMS recommendation

I typically use rails models and typus as my CMS as it gives the most flexibility, plus typus is just brilliant. I'm starting a new rails 3 app, and typus isn't rails3 compatible yet. I'm looking around for a CMS that'll work in rails 3. I still want to be able to write my views in haml (rather than some custom templating lang) and need ...

How to sort objects in a many-to-many relationship in ruby on rails?

I've been trying to deal with this problem for a couple of hours now and haven't been able to come up with a clean solution. It seems I'm not too good with rails... Anyway, I have the following: In code: class Article < ActiveRecord::Base has_many :line_aspects has_many :aspects, :through => :line_aspects #plus a 'name' field ...

Changing the id parameter in Rails routing

Using Ruby on Rails 3's new routing system, is it possible to change the default :id parameter resources :users, :key => :username come out with the following routes /users/new /users/:username /users/:username/edit ...etc I'm asking because although the above example is simple, it would be really helpful to do in a current projec...

New Rails project -- Rails2 or Rails3?

I have this new project I need to build. I want to have at least started on it by the end of this month. So which version should I use though? Should I just stick with the stable Rails2 or try to use Rails3 so I won't have to migrate later? Which one would you suggest for someone that is still learning Rails? ...

How Should I Generate Trade Statistics For CouchDB/Rails3 Application?

My Problem: I am trying to developing a web application for currency traders. The application allows traders to enter or upload information about their trades and I want to calculate a wide variety of statistics based on what the user entered. Now, normally I would use a relational database for this, but I have two requirements that...

Rails3 and safe nl2br !

Hi, I have a system for the users to be able to post comments. The comments are grasped into a textarea. My problem is to format the comments with br tag to replace \n In fact, i could do something like that s.gsub(/\n/, '<br />') But the xss protection including in rails escapes br tags. So i could do this s.gsub(/\n/, '<br />...

Problem with automatic Login into subdomain after signup -- Rails 3, Authlogic, Subdomain-fu

Hi, I am using rails 3.0.0.beta3 to implement authlogic and subdomain-fu. And, I have a problem with automatic login into subdomain after signup. The scenario is : I have a signup form where an account and an admin user for that account are created simultaneously. Each time a new account is created, a separate subdomain is assigned to...

How/When/Where to Extend Gem Classes (via class_eval and Modules) in Rails 3?

What is the recommended way to extend class behavior, via class_eval and modules (not by inheritance) if I want to extend a class buried in a Gem from a Rails 3 app? An example is this: I want to add the ability to create permalinks for tags and categories (through the ActsAsTaggableOn and ActsAsCategory gems). They have defined Tag a...

How do I specify an action on a resource in a namespace in rails 3?

I have a resource :products in a namespace :shop, like this: namespace :shop do resources :products root :to => 'products#index' end When running rake routes it outputs the following: edit_shop_product GET /shop/products/:id/edit(.:format) {:action=>"edit", :controller=>"shop/products"} But when I use the edit_shop_product_p...

How Do I Prevent Rails From Treating Edit Fields_For Differently From New Fields_For

I am using rails3 beta3 and couchdb via couchrest. I am not using active record. I want to add multiple "Sections" to a "Guide" and add and remove sections dynamically via a little javascript. I have looked at all the screencasts by Ryan Bates and they have helped immensely. The only difference is that I want to save all the section...

Rails 3: How to handle sessions in test scope?

Hi, coming from rails 2.3.5 I am used to do something like that: class MyControllerTest < ActionController::TestCase test 'should get index if logged in' do session = method_to_create_a_valid_session # in test_helper.rb get :index, {}, {:id => session.id} assert_response :success # redirect would happen if not lo...

Rails plugin for generating dynamic / ajax crud interfaces compatible with Rails 3 beta?

Anyone know of some good gems or plugins to create dynamic / ajax crud interfaces for Rails 3 projects? I know active scaffold was popular before and it's been awhile since I have used it / any other gems similar to this (I usually just write it myself). I like the direction that the formtastic gem (http://github.com/justinfrench/formta...

mongoid, set_table_name & attr_accessible

Hi! I'm using rails3 edge and mongoid 2beta6 with ruby 1.9.2-head. How can I manually change the table name, just like set_table_name for ActiveRecord? For example my model Signup should use the table "users" for storage, not "signups". Another question is how to implement the bevahior of attr_accessible AR provides? Thanks, Corin ...

DataMapper: using auto_migrate! with many-to-many dependencies?

Hi, I'm trying to migrate my app from MySql to Postgresql, using Rails3-pre and the latest DataMapper. I have several models which are related through many-to-many relationships using :through => Resource, which means that DataMapper creates a join table with foreign keys for both models. I can't auto_migrate! these changes, because I...

Build a gem with native extension (Gem::Installer::ExtensionBuildError)

I have the following configuration: uname -a : Linux 2.6.24.2 i686 GNU/Linux (Ubuntu) ruby -v : ruby 1.9.0 (2007-12-25 revision 14709) [i486-linux] rails -v : Rails 3.0.0.beta3 gem -v : 1.3.5 rake --version : rake, version 0.8.7 make -v : GNU Make 3.81 gem env : RUBYGEMS VERSION: 1.3.5 RUBY VERSION: 1.9.0 (2007-12-25 patchlevel 0) [i4...

how to return clean javascript from a rails3 custom view helper?

Using Rails 3: In my update.js.erb file I found I was repeating a lot of stuff. So I tried to put it all into a helper. But I'm having trouble getting the helper to give back clean javascript. It puts in \&quot; everywhere instead of " Here's what I started with: <% if @list.show_today %> $("#show_today_check_<%= @list.id %>").rem...

Authlogic and Single table inheritance

Hi, I have some models such as: class User < ActiveRecord::Base acts_as_authentic end class Admin < User end class Superadmin < Admin end And some controllers such as: class UserSessionsController < ApplicationController def new @user_session = UserSession.new end def create @user_session = UserSession.new(params[...

Rails3 own scaffold generator

./script/rails g generator admin class AdminGenerator < Rails::Generators::NamedBase def self.source_root @source_root ||= File.expand_path('../templates', __FILE__) end def manifest #I know I can copy my template files with the 'template' method #How I can generate a migration, and a model here ? end end ...