ruby-on-rails3

Getting "uninitialized constant User" when trying to install Typus (Rails 3.0)

I'm trying to install Typus on Rails 3.0. I already had Devise installed and, since Typus consistently gave a routing error with unknown route to .../admin, I uninstalled Devise. This seems to have gotten me further, since browsing to .../admin now redirects to .../admin/dashboard which apparently is where a new installation of Typus is ...

Getting Rspec + autotest working on windows

I have installed growl + rspec + autotest on my windows 7 machine. From the command prompt, when I type 'rspec spec/' it doesn't work. The tests will only run if I use 'rake spec/' + 'autotest'. Also, I am running these tests: http://railstutorial.org/chapters/static-pages#code:default_pages_controller_spec (i.e. very, very trivial) and...

Rails 3 - When loading a partial how to Combine a String (comment_) with a variable

I have the following: commentable.id =3131 In the partial: <%=f.text_area :content, :id=> 'comment_content_' commentable.id %> I want it to make: <textarea id="comment_content_3131" /> How do I combine the string with a variable in the partial? Thanks ...

Rails3 subdomain routing

I am trying to port over my Rails 2.3.5 app to Rails 3, and having trouble with the following route configurations: ActionController::Routing::Routes.draw do |map| map.app '', :controller => 'projects', :action => 'index', :conditions => {:subdomain => true} map.with_options :controller => 'site', :action => 'page', :sub...

Objects don't appear in test database when running specs

When saving an object by calling Entity.create(:name => "Entity1") from the Rails console in the testing environment (RAILS_ENV=test rails console) the "Entity1" object correctly appears in the test database (MySQL) when checking it with a mysql client. But when doing the same stuff in an rspec file (entity.create(:name => "Entity1"); sl...

Does rake db:populate work in Rails 3?

I'm having huge problems with my populate.rake file - after importing my existing file from my Rails 2.3.5 installation, Rails 3 wants nothing to do with it. I'm getting tens (if not hundreds) of errors in my console, many of them for simple statements, and some even in the middle of a string of plaintext. Has the syntax changed for Rai...

Turn off transactional fixtures for one spec with RSpec 2

How do I turn off transactional fixtures for only one spec (or Steak scenario) with RSpec 2? I tried some things found on the web without any success. This leads to an undefined method exception. describe "MyClass without transactional fixtures" do self.use_transactional_fixtures = false ... end This simply does nothing (transac...

Rails 3 routes with extended regex :constraints - bug?

I have the following route in my Rails 3 app. post 'games/:id/:task/:card_id' => 'games#perform', :as => :perform ...which allows, obviously, such requests as button_to("Foo", {card_id=>2, :action=>:perform, :task=>"foo"}), mapping to the URL /games/1/foo/2. I'd like to restrict the set of tasks the route matches. The Rails API docs ...

How to receive email via IMAP protocol in Rails 3

What is the best way to receive email via IMAP protocol in Rails 3? ...

Rails 3.0 - is there a built-in search functionnality in any of ActiveRecord classes ?

Dear all, I'm kind of new to rails - I'm currently learning by developping a web-app, similar to the Agile Rails book (with iteration and all). Knowing rails, I know there's a great way to search in the database. So my question simply is : what is the good way to do so ? - the rails way. Search criteria are classics (keywords in sente...

How do you test route constraints using RSpec

Given a couple of cities in the DB: City.first.attributes => {:id => 1, :name => 'nyc'} City.last.attributes => {:id => 2, :name => 'boston'} And a route like: match '/:city/*dest' => 'cities#do_something', :constraints => {:city => /#{City.all.map{|c| c.name}.join('|'}/} (so the constraints should evaluate to: /nyc|boston/) And a ...

problem to rspec update action using rails 3

I'm facing a problem with rspec and controllers i'm spec'ing an update action, so to do it i call the following code: put :update, :id => "1", :ntp => {:name=>'myservah'} My controller has the following code: def update if @ntp.update_attributes(params[:ntp]) flash.now[:notice] = "Successfully updated ntp." else flash.now[:err...

IP Geocoding in Rails 3

I'm looking for a working gem/plugin for rails3 that does IP geocoding, and ideally, distance calculations. geokit seems to be a popular choice, but it doesn't support rails3 yet. ...

How to localize ActiveModel error messages in Rails 3?

class User include ActiveModel::Validations validates_presense_of :first_name validates_length_of :last_name, :in => 3..20, :too_long => "pick a shorter last name", :too_short => "pick a longer last name" attr_accessor :first_name, :last_name end How do you localize error message(s) for :first_name localize error message(s) ...

Does Rails 2.3 and Rails 3.0 handle the displaying of arrays differently?

I am going through a video tutorial that was using Rails 2.3, and they did: <%= first_array = ['a', 'b', 'c'] %> When they did that, the output they got was: abc When I am trying to follow along, on my setup (Rails 3.0), I get: ["a", "b", "c"] Is this difference normal or did I do something incorrectly? Thanks. ...

How to Search multiple fields with single text field using metasearch and rails 3?

I've started using the metasearch gem http://metautonomo.us/projects/metasearch/ for a ruby on rails 3 app after seeing it recommended in another stackoverflow post. I would like to have a single text field on a search form that can search in multiple fields rather than have one text field for each. I just havn't been able to figure it ...

Rails 3 routes - how can I automatically map each action (with exceptions)?

I am a relative beginner at Rails 3 routing and it has now caused me enough pain that I want to figure out the real solution. A couple of details: I have some semi-restful controllers that contain some methods outside the standard seven new, create, edit, update, destroy, etc. Generally, I want my routes page to map everything to 'con...

Trying to get an value from a DataMapper join table and association

I have 3 classes - Mix, MixClip, and Clip. class Mix include DataMapper::Resource property :id, Serial # <removed other code for brevity> has n, :mix_clips has n, :clips, :through => :mix_clips end class MixClip include DataMapper::Resource property :id, Serial property :order, Integer belongs_to :mix be...

Rails 3 is messing with my flash!

I have a flash_helper that I inconveniently downloaded from some web tutorial, which is now coming back to whack me on the head. On the good side, I'm sure the many talented coders here will find this easy. :) # application_helper def flash_helper [:notice, :warning, :message].map { |f| content_tag(:div, flash[f], :class => f) if flash[...

Page Caching for rails 3

How to do page caching in rails 3. Is there is any plugins or gem for that? whether page_cache_fu will work for rails 3? ...