ruby-on-rails3

Is unobtrusive RJS files in Rails 3 considered a good idea?

I'm working on implementing javascript functionality in my rails 3 app. Now that rjs is supposedly unobtrusive (I honestly don't know a lot about rjs), is it still "evil"? It seems to me the downside may be a lack of testability, but partial page updates via rjs seem to be easier than jumping through the rails hurdles to make ajax requ...

Rails 3 - routing

I don't know how to make a link_to because I'dont have a nouveau_message_path in rake routes rake routes : GET /nouveau_message/.:id {:action=>"nouveau_message", :controller=>"messages"} routes.rb : controller :messages do get 'nouveau_message/.:id' => :nouveau_message end What is the best way to make a link_t...

Date formats in ActiveRecord / Rails 3

In my model, I have a departure_date and a return_date. I am using a text_field instead of the date_select so that I can use the JQuery datepicker. My app is based in the US for now but I do hope to get international members. So basically this is what is happening. The user (US) types in a date such as 04/01/2010 (April 1st). Of co...

using i18n with rails 3 problem

Hi! I've got some form for user registration and want to localize it via locales yml files. Especially errors from validations. For example, locale file: tr: activerecord: errors: models: user: attributes: name: blank: "can't be blank" it will return: name can't be blank in er...

Starting a Rails development server that is publicly accessible

Is there a way to start a Rails 3 development server (rails server) that is not bound to a specific IP address? I'd like for others working on a project with me to be able to use the application from remote locations. ...

Partial template submit_tag

Hello, I would like to create a login field everywhere on the top of my page, so I've add a : in application.html.erb : <%= render :partial => 'sessions/new' %> in .../views/sessions/_new.html.erb <%= form_tag do %> <div> <label for="name">Email :</label> <%= text_field_tag :name, params[:name] %> <label for="password...

rails: how do I build an active-relation scope to traverse many tables?

I have these tables and relationships: user has_many projects project has_many tasks task has_many actions I would like to build a scope that allows me to select all of the current users actions, regardless of what project or task they belong to. Thanks ...

Using the MongoDB Ruby driver in Rails? (without an object mapper)

I have recently been getting my feet wet in MongoDB using Mongoid w/ Rails 3, but I'm now interested in learning the low level MongoDB features using only the Ruby driver, and trying some map/reduce that would not be possible through Mongoid (afaik) I'm not entirely sure where in Rails I should be setting up the db connections etc, and ...

Change param name to nested resource parent

I have this routes: resources :tags do resources :comments end so the :create action for the comments has the following form tag_comments POST /tags/:tag_id/comments(.:format) how can i change the paramenter name from :tag_id to :commentable_id? ...

Rails3: how to use relational algebra to replace SQL-constructions like NOT and OUTER JOIN

There are two models Post and Comment. I should get all posts, which have no comments with specific tag. How can I do this using new Rails 3 features such relational algebra (arel). SQL-solution should be something like this: SELECT `posts`.* FROM `posts` LEFT OUTER JOIN `comments` ON `posts`.`id` = `comments`.`post_id` WHERE...

Rails 3 Initializers: No such file to load

I am trying to use the Sunlight API gem with a Rails project. I have installed the gem and can successfully use it from irb. However, when I put the require statement (require 'sunlight') in sunlight.rb in config/initializers, I get the following error: /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta3/lib/active_support/depe...

Rails 3 path for edit and new actions in a basic form view

Hi, I have the following routes: resources :categories do resources :articles end And the following views: # edit.erb and new.erb files: <%= render :partial => 'form' %> # top of _form.html.erb file: <%= form_for category_article_path(@article.category, @article) do |f| %> But I have some troubles with the given path. I work w...

Arel: How to cleanly join multiple conditions with OR?

In my Rails app, I loop through an array to create a list of conditions that must be joined by OR. Below is the basic flow of how I currently do so. conditions = nil set.each do |value| condition = value.to_condition conditions = conditions ? conditions.or(condition) : condition end Obviously, it's not beautiful, but I still don't...

How do I do a join in ActiveRecord after records have been returned?

I am using ActiveRecord in Rails 3 to pull data from two different tables in two different databases. These databases can not join on each other, but I have the need to do a simple join after-the-fact. I would like to preserve the relation so that I can chain it down the line. here is a simplified version of what I am doing browsers ...

:any option for rails 3 routes

In rails 2 you can use the :any option to define a custom route that responds to any request method e.g. map.resources :items, :member => {:erase => :any} rails 3 doesn't seem to support the :any option resources :items do get :erase, :on => :member # works any :erase, :on => :member # doesn't work end does anyone know if this ...

Unit test with Authlogic on Rails 3

Hello, I would like to write some unit test with a logged user using Authlogic. To start right, I used some code hosted in http://github.com/binarylogic/authlogic_example. But I get an error after rake test, because of "test_helper.rb" and the following class: class ActionController::TestCase setup :activate_authlogic end Here is...

Uninstall Rails 3 with dependencies?

I like that Rails 3 is so easy to install: gem install rails --pre, and all of the dependencies are automatically installed for you. But, what about uninstalling it? If I just do gem uninstall rails, I still have actionmailer (3.0.0.beta3) actionpack (3.0.0.beta3) activemodel (3.0.0.beta3) activerecord (3.0.0.beta3) activeresource (3.0....

Rails 3 Toolbar render

In my website toolbar's I would like to display the number of unread messages in a red circle, So I think the best way is to create a method in ApplicationController named update_notification : def update_notification @notification = 42 # 42 is just for test end and in application.html.erb, I display : <%= render :par...

How do you architect complex Rails systems

A while back I wrote this blog post (http://rywalker.com/chaos-2010) which didn't get any responses - my blog doesn't get a lot of traffic ;) So I want to try re-asking the same question here and maybe get some response. We have the following systems (and more) that we push/pull data from one app to another: Hosted CRM (InsideSales.co...

Uninitialized content when trying to include ActionController::UrlWriter in model

I'm using Rails 3 beta 4 and trying to include ActionController::UrlWriter in my model, which is the correct way to go about it as far as i can tell, but i get "Uninitialized Constant ActionController::UrlWriter". Any idea why that would be? Did it move in rails 3? ...