ruby-on-rails3

Could Rails 3.0's "gem install rails" or "bundle install" install a sqlite3.dll as well?

Rails 3.0 installation on Windows was almost seamless, except it'd still just say sqlite3.dll is missing and I think the solution is to find it and then put into one of your path such as c:\ruby192\bin or c:\windows ? Supposedly, can gem install or bundle install actually put it somewhere that is usable? ...

Rails 3 and undo last action button

Which solution would you prefer to use with Rails 3 in order to provide gmail like undo option instead of confirmation popups? I would like to allow user to undo last action, which would then revert the changes in tables made by that action. So far I was trying to get things done using Memento gem. Its not ideal, but things worked. Th...

What is the best way to structure a multi-page form to create and edit models in a database?

I'm fairly new to Rails. What is the best way to design/structure a multi-page form in Rails? I would like the form to create a new record in the database immediately when the first page of the form is submitted, and for each subsequent page of the form to update that record in the database. The reason I want the record created immedi...

HAML block returning `0` on yield?

I just upgraded to Rails3, Ruby 1.9.2 and the latest HAML gem. This code used to work: = allowed? do = link_to('New', new_video_path) Now allowed? yields 0. It works if I do: = allowed?{ link_to('New', new_video_path) } What gives? ...

JQuery and Rails 3 ajax:failure callback

I'm using Rails 3 and JQuery 1.4.2 and am trying to bind to the ajax:failure callback on a given remote form submission. The callback works fine, however, the xhr variable that's passed back seems to lose the responseText attribute somehow. Here's what my code looks like: _form.html.haml = form_for(object, :remote => true) do |f| = ...

Flash message with remote actions with Rails3

Hello, I have a silly question. I'm stuck on that and i don't know how to solve it :) I have some basic actions like create and destroy comments. I have added the remote => true attribute. My actions are rendered with a create.js.haml and a destroy.js.haml. $(".comments").prepend("#{escape_javascript(render(@comment))}"); $("#commen...

autotest on ubuntu does nothing

Running either $autotest or $autotest -f gives the same result: # Waiting since [timestamp] Changing a controller or spec file just gets that line repeated (with a newer timestamp). If I try $autotest -v, it does not include the spec or controller among the list of files for which no tests match, which I suppose is good; but it doesn't...

ruby 1.9.2 strange warning when running cucumber specs

Hi, I just updated to use rails 3 and tried my first project with rails 3. When I run my cucumber specs then I get following strange warnings /home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string /home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/uti...

Strange DoubleRenderError in Rails 3

I'm trying the standard redirect_to some_path and return syntax but for some reason Rails 3 isn't liking this. class MyController < ApplicationController def some_action redirect_to "http://www.google.com" return end end Gives me the standard error message: Render and/or redirect were called multiple times in this action....

Rails3 RSpec is wiping wrong database?

I am trying to get my hands on Rspec2 with Rails3 (never used rspec before). I have rspec-rails 2.0.0.beta20. After introducing some basic tests into spec/models and running rspec spec/models/user_spec.rb everthing is fine. However if I just run rake spec My development database is beeing wiped out. Even if I specify the environme...

How to use routing helpers in a model with Rails 3?

Hello, In a model callback I make an API call and need to give the API some URLs. Those URLs would be easily generated by a routing helper. The solution given in this answer does not work anymore in Rails 3. Any solution? Thanks :) ...

Internationalization for constants-hashes in rails 3

Could you tell me whats the best practice for storing constants with internationalization in rails3? f.e. i want to have a constant-hash for haircolours for my user model: # btw: how can I store such hashes in the locales.yml-files? # en.yml HAIR_COLOURS = { "brown" => 0, "white" => 1, "red" => 2, "dark-brown" => 3...} # de.yml HAIR_C...

TypeError: can't convert Post into Array

I'm using Rails 3 and will_paginate. Pagination works fine in my Posts controller but in my Tags controller I get an error on the second Tag id. Here's the error: TypeError in TagsController#show can't convert Post into Array ... app/controllers/tags_controller.rb:8:in `show' tags_controller.rb#show: def show @tag = ActsAsTaggab...

Factory Girl with has many relationship (and a protected attribute)

Hello, I have this kind of relation: class Article < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :article attr_protected :article_id end The default scenario inside controllers looks like: @article = Article.create(:title => "foobar") @comment = @article.comments.create(:content => ...

Rails 3 api - Locations of most common methods.

Hi, I am new to Ruby on Rails (3). I would like to study some of the docs more thoroughly, but I am having a problem locating them. Under which namespaces do I find the most common methods for tasks dealing with Views, Controllers, Migrations and Models? ...

How can I access rails 2.3.x commands when rails 3 is installed?

I'd like to play around with rails 3, but I'm still used to rails 2.3.8 so I have them both installed. Wanting to make a quick rails app to demonstrate how a plugin works, I want to run the command rails test_app but since I have rails 3 installed, I have to run rails new test_app but that will generate a rails 3 app. Is there a way arou...

Can someone describe to me what RSpec 2 is doing in this?

I have been attempting to dive into RSpec 2 but its auto generated controller specs do not work for any version of RSpec 2 with any version of Ruby or any version of Rails. Maybe I'm missing something obvious? def mock_category(stubs={}) @mock_category ||= mock_model(Category, stubs).as_null_object end describe "GET show" do it "as...

How to cancel scheduled job with delayed_job in Rails?

Title says it all basicly. I am scheduling a job to run in say, 10 minutes. How to properly cancel this particular job without using any kind of dirty extra fields in model and so on. Is there any call to remove particular job, or jobs related to specific model, instance, etc? ...

How to completely remove Rspec and its generated files, and reinstall them into a project?

Is it possible to completely remove rspec from a project, and then reinstall it again? The reason I ask is because I had started my project on Rails 3 beta, and now that the new one has come out, the new rspec conflicts and nothing passes. But if I start a new project, everything seems to work as expected. ...

ActiveRecord OR query

This is an embarrassing noob question, but... How do you do an OR query in Rails 3 ActiveRecord. All the examples I find just have AND queries. Edit: without using a SQL string! ...